Typescript issue with getter within getter #2685
-
ReproductionSteps to reproduce the bugOn line 16, no errors, fine. On line 19, Expected behaviorNo TS error on line 19 Actual behaviorAdditional informationFun fact: when not using the return value of // This is OK
addedIdWorkaround () {
const test = useStore().added(this.currentId)
return test.result
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I'm using TS 5.4.5 |
Beta Was this translation helpful? Give feedback.
-
You probably need to explicitly type some of the getters or actions to avoid a cyclic type reference (that’s why you might see any) Edit: yes that's what's missing: export const useOtherStore = defineStore('second_store', {
getters: {
currentId() {
return 1
},
addedId() {
return useStore().added(1).result
},
addedIdBug(): number {
return useStore().added(this.currentId).result
},
},
}) |
Beta Was this translation helpful? Give feedback.
You probably need to explicitly type some of the getters or actions to avoid a cyclic type reference (that’s why you might see any)
Edit: yes that's what's missing: