How to set the type for the state object in pinia?
The type of this.previousPieceSelected is inferred from the initial state, and it’s currently initialized to undefined, so it thus has a type of undefined (meaning it can only be assigned a value of undefined). Use type assertion on the initial undefined value (i.e., the as keyword plus the desired type of Piece | undefined). Also … Read more