I have a store.
export const useGameStore = defineStore("game", {
state: () => gameBaseState,
getters: {
foundMarkers(state): Marker[] {
return state.markers.filter((m) => m.found);
},
...
},
actions: {
closeAll() {...},
nextMissed() {...},
previousMissed() {...},
removeFlashId(id: string) {...},
guess(pos: Coord) {
...
if (this.foundMarkers.length >= this.toFind) {
this.setScore();
this.status = GameStatus.Passed;
}
},
},
});
In the guess()
action and all over the other actions the getter values aren't found. I get...
Property 'foundMarkers' does not exist on type '{ closeAll(): void; nextMissed():
void; previousMissed(): void; removeFlashId(id: string): void; flash(text: string,
type?: string, t?: number): void; loadLevel(levelIndex: any): void; ... 10 more ...;
guess(pos: Coord): void; } & { ...; } & _StoreWithState<...> & _StoreWithGetters<...>
& PiniaCustomProperties<...>'.
Which is basically all the actions. It seems like it can't infer the type of the getters (all the code runs fine, and all the getters can be accessed fine).
Have I missed something?
So far I have made sure that the foundMarkers
getter is typed
foundMarkers(state): Marker[] {
^^^^^^^^
As recommended in other forums, but beyond this I'm a bit lost in how to correctly format this.
I have also checked that the actions themselves are formatted correctly (and I think they are).