types: accept defineComponent return types in app.mount

This commit is contained in:
Evan You 2019-12-24 11:04:35 -05:00
parent 59c595c1e8
commit 7df5e70c83
2 changed files with 24 additions and 2 deletions

View 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

View 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')
})