From 8f2b51638a97a8060ccec4d6230fc05baad2d69c Mon Sep 17 00:00:00 2001 From: ktsn Date: Sat, 21 Jul 2018 12:51:18 +0900 Subject: [PATCH] fix(types): relax the return type of props default option --- types/options.d.ts | 2 +- types/test/options-test.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index cc58affe6a1..25eb8a0fdf3 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -133,7 +133,7 @@ export type PropValidator = PropOptions | Prop | Prop[]; export interface PropOptions { type?: Prop | Prop[]; required?: boolean; - default?: T | null | undefined | (() => object); + default?: T | null | undefined | (() => T | null | undefined); validator?(value: T): boolean; } diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 6fc9e356451..17a54fd360b 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -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