Skip to content

Commit a9eb198

Browse files
ktsnyyx990803
authored andcommitted
fix(types): relax the return type of props default option (#8537)
1 parent 1e1ce0c commit a9eb198

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

types/options.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export type PropValidator<T> = PropOptions<T> | Prop<T> | Prop<T>[];
133133
export interface PropOptions<T=any> {
134134
type?: Prop<T> | Prop<T>[];
135135
required?: boolean;
136-
default?: T | null | undefined | (() => object);
136+
default?: T | null | undefined | (() => T | null | undefined);
137137
validator?(value: T): boolean;
138138
}
139139

types/test/options-test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ Vue.component('union-prop', {
7979
}
8080
});
8181

82+
Vue.component('prop-with-primitive-default', {
83+
props: {
84+
id: {
85+
type: String,
86+
default: () => String(Math.round(Math.random() * 10000000))
87+
}
88+
},
89+
created() {
90+
this.id;
91+
}
92+
});
93+
8294
Vue.component('component', {
8395
data() {
8496
this.$mount

0 commit comments

Comments
 (0)