Skip to content

Commit

Permalink
fix(types): relax the return type of props default option
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn committed Jul 21, 2018
1 parent 21112ec commit 8f2b516
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 8f2b516

Please sign in to comment.