From 7e8c3d08678f3974374e52247b73f90d925a29d8 Mon Sep 17 00:00:00 2001 From: Carlos Date: Mon, 18 Mar 2019 11:56:13 +0000 Subject: [PATCH 1/2] fix(types): allow using functions on the PropTypes (#9692) --- types/options.d.ts | 2 +- types/test/options-test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index dcb38614ed3..75616f5d5a5 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -144,7 +144,7 @@ export interface RenderContext { injections: any } -export type Prop = { (): T } | { new(...args: any[]): T & object } +export type Prop = { (): T } | { new(...args: any[]): T & object } | {new(...args: string[]): Function;} export type PropType = Prop | Prop[]; diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 2c67efe0665..b8bdc098312 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -68,12 +68,14 @@ interface ICat { foo: any, bar: object } +type ConfirmCallback = (confirm: boolean) => void; Vue.component('union-prop', { props: { cat: Object as PropType, complexUnion: { type: [User, Number] as PropType }, kittyUser: Object as PropType, + callback: Function as PropType, mixed: [RegExp, Array], object: [Cat, User], primitive: [String, Number], @@ -84,6 +86,7 @@ Vue.component('union-prop', { this.cat; this.complexUnion; this.kittyUser; + this.callback(true); this.mixed; this.object; this.primitive; @@ -281,6 +284,18 @@ Vue.component('component', { delimiters: ["${", "}"] }); + +Vue.component('custom-prop-type-function', { + props: { + callback: Function as PropType<(confirm: boolean) => void>, + }, + methods: { + confirm(){ + this.callback(true); + } + } +}); + Vue.component('provide-inject', { provide: { foo: 1 From 8e0d56ab6c5b871bc039bda787373b732318dc79 Mon Sep 17 00:00:00 2001 From: Carlos Date: Mon, 18 Mar 2019 16:51:17 +0000 Subject: [PATCH 2/2] fix(types): unifying code style (#9692) --- types/options.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index 75616f5d5a5..3fe7a9b7aaf 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -144,7 +144,7 @@ export interface RenderContext { injections: any } -export type Prop = { (): T } | { new(...args: any[]): T & object } | {new(...args: string[]): Function;} +export type Prop = { (): T } | { new(...args: any[]): T & object } | { new(...args: string[]): Function } export type PropType = Prop | Prop[];