-
-
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: can't infer prop names and types when contains any type prop #6841
Comments
Indeed it does not work if it has any typed props definition. I'm not sure about the reason, though. @HerringtonDarkholme @DanielRosenwasser |
I'm currently not by a computer but I'll guess a bit. Right now it's probably an assignability error for props in general, but we can do better there in future versions of TypeScript. I'm currently on a branch where this works better. The thing is that even on this branch, the best inference I can get is |
With #6850 , you can do this. import Vue, { VNode } from "vue";
Vue.extend({
name: "Workaround",
props: {
foo: { type: String },
bar: {} as Prop<any>
},
render(h): VNode {
return h("div", this.foo);
}
}); I think inferring |
Closing this one - please keep an eye on #6856 (to be merged for 2.6) |
Version
2.5.2
Reproduction link
https://github.com/wonderful-panda/vue-sandbox
Steps to reproduce
Compile this code by tsc
or clone from repro link and
npm install && npm run build
What is expected?
Successfully compiled.
And
this.foo
is treated as string,this.bar
is treated as any.What is actually happening?
Failed to compile.
Workaround:
The text was updated successfully, but these errors were encountered: