No Ts check between actions inside Pinia Store #1274
Replies: 3 comments 1 reply
-
In my experience, typescript + implicit this doesn't really play nice. Just try to use vue2 with typescript and write your components with If I were in your shoes I would refactor your store into composition API. export const useStore = defineStore('main', () => {
const state = reactive({
counter: 0,
name: 'Boo'
} as NameDGZ)
const giveNewName = (name: string) => {
state.name = name;
};
const concatNames = () => {
giveNewName(87564);
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Make sure strict is set to true in your tsconfig and no option is overriding it |
Beta Was this translation helpful? Give feedback.
0 replies
-
What about: const state = (): nameGDZ => ({
counter: 0,
name: 'Boo'
})
const actions = {
giveNewName(name: string) {
// ...
},
concatNames() {
actions.giveNewName(87564); // TS error
},
}
export const useStore = defineStore('main', {
state,
getters,
actions,
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
So inside my Pinia Store, I have actions; but they don't seem to have autocomplete or check the params when I use them inside the store. The same happens when referencing the state.
So for example I do:
Any idea why is this happening?
Thanks!!!!!
Beta Was this translation helpful? Give feedback.
All reactions