-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript may be can not infer the props type #6924
Comments
If you want to strict it, you need to manually annotate your props type vid |
Thanks a lot. <script lang="ts">
import Vue from 'vue'
interface setFunction {
(argu1: number, argu2: number):string
}
export default {
props: {
test: Object as (() => setFunction)
},
data() {
this.test(1,1);
return {}
}
}
</script> After I reference #6865, the this.test can get the correct parameter types |
Currently, no.
|
Thanks. I will learn it. |
Angular's AOT Compiler can check template's type also with So I think Vue's template compiler can check template's type. |
FYI vuejs/vetur#681 |
@ktsn That's so great job! Is it only work on vetur? Is it possible to run with Vue Cli's lint? |
Yeah, I'm still sticking with Atom, even though MS bought Github and technically now owns Atom too... It's critical to have type checking in templates, I find that currently it's the main source of typos/bugs in my typescript vue apps- |
Version
vue 2.5.2
typescript 2.5.3
Reproduction link
https://jsfiddle.net/chrisvfritz/50wL7mdz/typescript
Steps to reproduce
Typescript may be can not infer the props type. eg:
this.test('aa', 'aa') can invoke correct.
Now Vue can not get the parent's(props) function type?
What is expected?
types error.
What is actually happening?
can run success.
The text was updated successfully, but these errors were encountered: