-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Vue2.7] A type error. method can't be called in option "data" #12944
Comments
This might be the same issue of computed referencing other computed properties needing an explicit type annotation. Have you tried this: defineComponent({
data(): { data1: number } {
return {
data1: this.method1(),
}
},
methods: {
method1(): number {
return 1
}
}
}) |
@posva I just tried it and the problem still exists |
Illegal usage |
The error will gone if you move TS Playground link with relevant code defineComponent({
methods: {
foo(): number {
return 1
}
},
data() {
return {
data1: this.foo(),
}
},
}) It's due to the infer order of typescript. Releated to microsoft/TypeScript#52849 |
Version
2.7.14
Reproduction link
github.com
Steps to reproduce
pnpm install
(or use npm, yarn)pnpm type-check
(actual command isvue-tsc --noEmit
)What is expected?
no error
What is actually happening?
An error was reported: The method in option
methods
could not be found in the optiondata
The main code in the repository is:
The text was updated successfully, but these errors were encountered: