From 464973924399c98bc3d94a1e599f4eac6ac8e2f4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 9 Sep 2017 13:07:47 -0700 Subject: [PATCH 1/2] Simplify 'CreateElement', remove potential error in 'AsyncComponent' return type. --- types/options.d.ts | 2 +- types/test/options-test.ts | 5 ----- types/vue.d.ts | 12 ++---------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index 3475cb45bc4..07e6a10a91c 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -19,7 +19,7 @@ interface EsModuleComponent { export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = ( resolve: (component: Component) => void, reject: (reason?: any) => void -) => Promise | Component | void; +) => Promise | void; /** * When the `Computed` type parameter on `ComponentOptions` is inferred, diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 5b79826d741..eb5003cce30 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -163,11 +163,6 @@ Vue.component('component', { createElement(() => Vue.component("component")), createElement(() => ( {} as ComponentOptions )), - createElement(() => { - return new Promise((resolve) => { - resolve({} as ComponentOptions); - }) - }), createElement((resolve, reject) => { resolve({} as ComponentOptions); reject(); diff --git a/types/vue.d.ts b/types/vue.d.ts index ddcdf992706..6150089ca85 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -19,17 +19,9 @@ export interface CreateElement { // empty node (): VNode; - // element or component name - (tag: string, children: VNodeChildren): VNode; - (tag: string, data?: VNodeData, children?: VNodeChildren): VNode; - // component constructor or options - (tag: Component, children: VNodeChildren): VNode; - (tag: Component, data?: VNodeData, children?: VNodeChildren): VNode; - - // async component - (tag: AsyncComponent, children: VNodeChildren): VNode; - (tag: AsyncComponent, data?: VNodeData, children?: VNodeChildren): VNode; + (tag: string | Component | AsyncComponent, children: VNodeChildren): VNode; + (tag: string | Component | AsyncComponent, data?: VNodeData, children?: VNodeChildren): VNode; } export interface Vue { From c953990a1fe05b1d1020e93d2be5cb4c587d65c1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 11 Sep 2017 11:45:42 -0700 Subject: [PATCH 2/2] Simplify down to two overloads. --- types/vue.d.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/types/vue.d.ts b/types/vue.d.ts index 6150089ca85..ae30d2cebb3 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -16,12 +16,8 @@ import { VNode, VNodeData, VNodeChildren, ScopedSlot } from "./vnode"; import { PluginFunction, PluginObject } from "./plugin"; export interface CreateElement { - // empty node - (): VNode; - - // component constructor or options - (tag: string | Component | AsyncComponent, children: VNodeChildren): VNode; - (tag: string | Component | AsyncComponent, data?: VNodeData, children?: VNodeChildren): VNode; + (tag?: string | Component | AsyncComponent, children?: VNodeChildren): VNode; + (tag?: string | Component | AsyncComponent, data?: VNodeData, children?: VNodeChildren): VNode; } export interface Vue {