Having this store here :
interface Task {
id?: string;
name: string;
done: boolean;
}
interface TodoState {
tasks: Task[];
loading: boolean;
}
export const useTodoStore = defineStore({
id: 'todo',
state: (): TodoState => ({
tasks: [],
loading: false,
}),
getters: {},
actions: {
async addTask(name: string): Promise<void> {
this.loading = true;
this.tasks.push({ name, done: false, id: generateID() });
await sleep(200);
this.loading = false;
},
},
});
I don't understand why when I hover "tasks" in the action its type is not Task[] but I get
(property) tasks: {
id?: string | undefined;
name: string;
done: boolean;
}[]
here is the code in a stackblitz if needed
The same issue is observed when I get tasks outside of the store. In a component for example.