From 2599580bcadc9b58de00cd02fb20cbb02700da51 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 12 Oct 2018 22:07:08 -0400 Subject: [PATCH] types: further tweak createElement type inference --- packages/core/src/h.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/core/src/h.ts b/packages/core/src/h.ts index c461017d..c07e11f4 100644 --- a/packages/core/src/h.ts +++ b/packages/core/src/h.ts @@ -54,53 +54,51 @@ type OptionsComponent

= | (ComponentOptions

& { template: string }) | (ComponentOptions

& { render: Function }) +// TODO improve return type with props information interface createElement extends VNodeFactories { // element + (tag: string, children?: RawChildrenType): VNode ( tag: string, // TODO support native element properties data?: VNodeData & Differ | null, children?: RawChildrenType | RawSlots ): VNode - (tag: string, children?: RawChildrenType): VNode // fragment + (tag: typeof Fragment, children?: RawChildrenType): VNode ( tag: typeof Fragment, data?: ({ key?: Key } & Differ) | null, children?: RawChildrenType | RawSlots ): VNode - (tag: typeof Fragment, children?: RawChildrenType): VNode // portal + (tag: typeof Portal, children?: RawChildrenType): VNode ( tag: typeof Portal, data?: ({ target: any } & BuiltInProps & Differ) | null, children?: RawChildrenType | RawSlots ): VNode - (tag: typeof Portal, children?: RawChildrenType): VNode // object +

(tag: OptionsComponent

, children?: RawChildrenType): VNode

( tag: OptionsComponent

, data?: (P & BuiltInProps & Differ) | null, children?: RawChildrenType | RawSlots ): VNode -

(tag: OptionsComponent

, children?: RawChildrenType): VNode // functional +

(tag: FunctionalComponent

, children?: RawChildrenType): VNode

( tag: FunctionalComponent

, data?: (P & BuiltInProps & Differ) | null, children?: RawChildrenType | RawSlots ): VNode -

(tag: FunctionalComponent

, children?: RawChildrenType): VNode // class - >( - tag: new () => T & { $props: P }, +

(tag: new () => ComponentInstance

, children?: RawChildrenType): VNode +

( + tag: new () => ComponentInstance

, data?: (P & BuiltInProps & Differ) | null, children?: RawChildrenType | RawSlots ): VNode - >( - tag: new () => T & { $props: P }, - children?: RawChildrenType - ): VNode } export const h = ((tag: ElementType, data?: any, children?: any): VNode => {