Trying Vue 3 with TS & Pinia. Inside a component, everything is fine with but when I try , I'm gettings an error in VS Code: "Cannot find Module @/stores/todoList".
The same error with "import { storeToRefs } from 'pinia'" : Cannot find 'pinia'.
<script setup lang="ts">
import { useTodoListStore } from '@/stores/todoList'
import { storeToRefs } from 'pinia'
</script>
My Store:
import { defineStore } from 'pinia'
export const useTodoListStore = defineStore("todoList", {
state: () => ({
todoList: [],
id: 0
}),
actions: {
addTodo(item) {
this.todoList.push({ item, id: this.id++, completed: false })
},
deleteTodo(itemId) {
this.todoList = this.todoList.filter((object) => {
return object.id !== itemId
})
},
toggleCompleted(idToFind) {
const todo = this.todoList.find((obj) => obj.id === idToFind)
if (todo) {
todo.completed = !todo.completed
}
}
}
})