From 7963c01a67bed81dfb474198362a5a61e2ee009c Mon Sep 17 00:00:00 2001 From: terencez Date: Thu, 10 Oct 2019 00:17:42 +0800 Subject: [PATCH] types(runtime-core): simplify types in createComponentInstance() (#170) --- packages/runtime-core/src/component.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 0cdbf04be..10e0a7ef6 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -121,19 +121,19 @@ const emptyAppContext = createAppContext() export function createComponentInstance( vnode: VNode, parent: ComponentInternalInstance | null -): ComponentInternalInstance { +) { // inherit parent app context - or - if root, adopt from root vnode const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext - const instance = { + const instance: ComponentInternalInstance = { vnode, parent, appContext, - type: vnode.type as Component, - root: null as any, // set later so it can point to itself + type: vnode.type, + root: null!, // set later so it can point to itself next: null, - subTree: null as any, // will be set synchronously right after creation - update: null as any, // will be set synchronously right after creation + subTree: null!, // will be set synchronously right after creation + update: null!, // will be set synchronously right after creation render: null, renderProxy: null, propsProxy: null, @@ -178,7 +178,7 @@ export function createComponentInstance( rtc: null, ec: null, - emit: (event: string, ...args: unknown[]) => { + emit: (event, ...args) => { const props = instance.vnode.props || EMPTY_OBJ const handler = props[`on${event}`] || props[`on${capitalize(event)}`] if (handler) {