-
-
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
Export Prop type in main types file (vue/types/index.d.ts) #6850
Labels
Comments
Did you tried vue-property-decorator? import Vue from 'vue'
import { Prop, Component } from 'vue-property-decorator'
interface FooBar {
foo: string,
bar: string
}
@Component
export default class App extends Vue {
@Prop() foobar: FooBar;
} |
I like the idea. @sandangel This proposal is not related with decorators. It would help us declare |
I can do a PR if it's easier since this would be a very simple change. |
@ferdaber yes please. |
13 tasks
yyx990803
pushed a commit
that referenced
this issue
Dec 5, 2018
yyx990803
pushed a commit
that referenced
this issue
Dec 10, 2018
yyx990803
pushed a commit
that referenced
this issue
Dec 10, 2018
yyx990803
pushed a commit
that referenced
this issue
Dec 11, 2018
yyx990803
pushed a commit
that referenced
this issue
Dec 12, 2018
f2009
pushed a commit
to f2009/vue
that referenced
this issue
Jan 25, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem does this feature solve?
When attempting to declare a type for a complex object-type prop for a component, it's difficult to understand (without knowing exactly how the Props typing works) how to cast that specific prop to the interface you create.
The best way of doing it currently is to do this:
What does the proposed API look like?
It would be nice to expose the Prop generic type in vue/types/options.d.ts in the default types export so that we can simply use this:
This also extends to complex callback types if need be so that whenever the regular prop types via the primitive type constructors don't work, we can create an interface and cast it as
Prop<ICustomType>
and it just works.The text was updated successfully, but these errors were encountered: