Skip to content

Commit

Permalink
fix(types): relax the return type of props default option (#8537)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn authored and yyx990803 committed Sep 18, 2018
1 parent 1e1ce0c commit a9eb198
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export type PropValidator<T> = PropOptions<T> | Prop<T> | Prop<T>[];
export interface PropOptions<T=any> {
type?: Prop<T> | Prop<T>[];
required?: boolean;
default?: T | null | undefined | (() => object);
default?: T | null | undefined | (() => T | null | undefined);
validator?(value: T): boolean;
}

Expand Down
12 changes: 12 additions & 0 deletions types/test/options-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ Vue.component('union-prop', {
}
});

Vue.component('prop-with-primitive-default', {
props: {
id: {
type: String,
default: () => String(Math.round(Math.random() * 10000000))
}
},
created() {
this.id;
}
});

Vue.component('component', {
data() {
this.$mount
Expand Down

0 comments on commit a9eb198

Please sign in to comment.