]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types: accept defineComponent return types in app.mount
authorEvan You <yyx990803@gmail.com>
Tue, 24 Dec 2019 16:04:35 +0000 (11:04 -0500)
committerEvan You <yyx990803@gmail.com>
Tue, 24 Dec 2019 16:04:44 +0000 (11:04 -0500)
packages/runtime-core/src/apiCreateApp.ts
test-dts/defineComponent.test-d.tsx

index ce0a2371550768c5898dcc600f4297b26d69213c..fa50f0e8e319023d1b8d2d7e1c103c12c0d54425 100644 (file)
@@ -17,7 +17,10 @@ export interface App<HostElement = any> {
   directive(name: string): Directive | undefined
   directive(name: string, directive: Directive): this
   mount(
-    rootComponent: Component,
+    rootComponent:
+      | Component
+      // for compatibility with defineComponent() return types
+      | { new (): ComponentPublicInstance<any, any, any, any, any> },
     rootContainer: HostElement | string,
     rootProps?: Data
   ): ComponentPublicInstance
index 4024f7526dd299ecbc77106908042199053a4def..5ae79cfefc963c8441aef3d7a595a0cad03d423c 100644 (file)
@@ -1,5 +1,5 @@
 import { expectError, expectType } from 'tsd'
-import { describe, defineComponent, PropType, ref } from './index'
+import { describe, defineComponent, PropType, ref, createApp } from './index'
 
 describe('with object props', () => {
   interface ExpectedProps {
@@ -240,3 +240,22 @@ describe('type inference w/ options API', () => {
     }
   })
 })
+
+describe('compatibility w/ createApp', () => {
+  const comp = defineComponent({})
+  createApp().mount(comp, '#hello')
+
+  const comp2 = defineComponent({
+    props: { foo: String }
+  })
+  createApp().mount(comp2, '#hello')
+
+  const comp3 = defineComponent({
+    setup() {
+      return {
+        a: 1
+      }
+    }
+  })
+  createApp().mount(comp3, '#hello')
+})