From: Evan You Date: Sat, 13 Oct 2018 02:07:08 +0000 (-0400) Subject: types: further tweak createElement type inference X-Git-Tag: v3.0.0-alpha.0~1117 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2599580bcadc9b58de00cd02fb20cbb02700da51;p=thirdparty%2Fvuejs%2Fcore.git types: further tweak createElement type inference --- diff --git a/packages/core/src/h.ts b/packages/core/src/h.ts index c461017d1a..c07e11f484 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 => {