]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types(runtime-core): simplify types in createComponentInstance() (#170)
authorterencez <texvnars@gmail.com>
Wed, 9 Oct 2019 16:17:42 +0000 (00:17 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 9 Oct 2019 16:17:42 +0000 (12:17 -0400)
packages/runtime-core/src/component.ts

index 0cdbf04be281306be621142a86ea3c330fdeebb4..10e0a7ef696ed727384e196274b38e8327f37f23 100644 (file)
@@ -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) {