Store own properties typing with Nuxt 3 #1241
-
Reproductionno_reproduction Steps to reproduce the bug
Expected behaviorStore is able to resolve types of own properties. Example: import { defineStore } from 'pinia'
interface IState {
a: string
}
export const useObrazkiStore = defineStore('test', {
state: (): IState => ({
a: 'someString'
}),
actions: {
test() {
const a = this.a // <- EXPECTED: this.a is of type string
console.log(a)
}
}
}) Actual behaviorStore is not able to resolve own types: import { defineStore } from 'pinia'
interface IState {
a: string
}
export const useObrazkiStore = defineStore('test', {
state: (): IState => ({
a: 'someString'
}),
actions: {
test() {
const a = this.a // <- ACTUAL: this & this.a is of type any
console.log(a)
}
}
}) Additional informationVersions:
|
Beta Was this translation helpful? Give feedback.
Answered by
maxtomczyk
Apr 21, 2022
Replies: 2 comments 3 replies
-
Did you make sure you have |
Beta Was this translation helpful? Give feedback.
2 replies
-
Thanks for super fast response. Looks like |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for super fast response.
Looks like
strict: true
is partially answer for this question. Apparently nuxt 3 project created withnuxi
doesn't support TS by default (types and configuration must be manually added).