-
-
Notifications
You must be signed in to change notification settings - Fork 443
Add support of PropType checking in Vue 2 #66
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
Comments
hi @Hope410, you already can use PropType form import { defineComponent, PropType } from '@vue/composition-api'
export default defineComponent({
props: {
foo: Object as PropType<AnyTypeYouWant>
}
}) |
have you try defineComponent? as I know PropType only work for defineComponent, but not Vue.extend. |
PropType from vue works as well. So, i used defineComponent, and prop type infered correctly, thanks. But could you add support of Vue.extend? It would be very helpful for vue2 + typescript users, i think most of them use Vue.extend |
We need import Vue, { PropType } from 'vue';
const A = Vue.extend({
props: {
foo: String,
},
mounted() {
this.foo // string
}
});
const a = new A();
a.$props.foo // any check the source code, I'm not sure dose they have plan to improve |
I understood, anyway, thank you! |
@dynamite-ready The type inference provided by |
Thank you for very useful extension, it helps me a lot.
And it would be more helpful if you add PropType checking like when project uses vue 3.
Currently this feature doesn't support vue 2 projects :(
The text was updated successfully, but these errors were encountered: