fix: h.* shorthands should expect correct args type

This commit is contained in:
Evan You 2018-10-01 18:21:33 -04:00
parent 3fe047b4ac
commit aafecb319d

View File

@ -57,6 +57,8 @@ export type VNodeChildren =
| string // TEXT | string // TEXT
| null | null
export type RawVNodeChildren = VNodeChildren | unknown[]
export type Key = string | number export type Key = string | number
export type Ref = (t: RenderNode | MountedComponent | null) => void export type Ref = (t: RenderNode | MountedComponent | null) => void
@ -71,7 +73,7 @@ export function createVNode(
flags: VNodeFlags, flags: VNodeFlags,
tag: string | FunctionalComponent | ComponentClass | RenderNode | null, tag: string | FunctionalComponent | ComponentClass | RenderNode | null,
data: VNodeData | null, data: VNodeData | null,
children: VNodeChildren | null, children: RawVNodeChildren | null,
childFlags: ChildrenFlags, childFlags: ChildrenFlags,
key: Key | null | undefined, key: Key | null | undefined,
ref: Ref | null | undefined, ref: Ref | null | undefined,
@ -82,7 +84,7 @@ export function createVNode(
flags, flags,
tag, tag,
data, data,
children, children: children as VNodeChildren,
childFlags, childFlags,
key: key === void 0 ? null : key, key: key === void 0 ? null : key,
ref: ref === void 0 ? null : ref, ref: ref === void 0 ? null : ref,
@ -108,7 +110,7 @@ function normalizeClassAndStyle(data: VNodeData) {
export function createElementVNode( export function createElementVNode(
tag: string, tag: string,
data: VNodeData | null, data: VNodeData | null,
children: VNodeChildren, children: RawVNodeChildren | null,
childFlags: ChildrenFlags, childFlags: ChildrenFlags,
key?: Key | null, key?: Key | null,
ref?: Ref | null ref?: Ref | null
@ -123,7 +125,7 @@ export function createElementVNode(
export function createComponentVNode( export function createComponentVNode(
comp: any, comp: any,
data: VNodeData | null, data: VNodeData | null,
children: VNodeChildren | Slots, children: RawVNodeChildren | Slots,
childFlags: ChildrenFlags, childFlags: ChildrenFlags,
key?: Key | null, key?: Key | null,
ref?: Ref | null ref?: Ref | null
@ -180,7 +182,7 @@ export function createComponentVNode(
if (childrenType === 'function') { if (childrenType === 'function') {
// function as children // function as children
slots = { default: children } slots = { default: children }
} else if (Array.isArray(children) || (children as VNode)._isVNode) { } else if (Array.isArray(children) || (children as any)._isVNode) {
// direct vnode children // direct vnode children
slots = { default: () => children } slots = { default: () => children }
} else if (typeof children === 'object') { } else if (typeof children === 'object') {
@ -222,7 +224,7 @@ export function createTextVNode(text: string): VNode {
} }
export function createFragment( export function createFragment(
children: VNodeChildren, children: RawVNodeChildren,
childFlags?: ChildrenFlags, childFlags?: ChildrenFlags,
key?: Key | null key?: Key | null
) { ) {
@ -240,7 +242,7 @@ export function createFragment(
export function createPortal( export function createPortal(
target: RenderNode | string, target: RenderNode | string,
children: VNodeChildren, children: RawVNodeChildren,
childFlags?: ChildrenFlags, childFlags?: ChildrenFlags,
key?: Key | null, key?: Key | null,
ref?: Ref | null ref?: Ref | null