-import { defineCustomElement } from 'vue'
-import { expectType, describe } from './utils'
+import {
+ defineCustomElement,
+ defineComponent,
+ type VueElementConstructor
+} from 'vue'
+import { expectType, describe, test } from './utils'
describe('inject', () => {
// with object inject
}
})
})
+
+describe('defineCustomElement using defineComponent return type', () => {
+ test('with emits', () => {
+ const Comp1Vue = defineComponent({
+ props: {
+ a: String
+ },
+ emits: {
+ click: () => true
+ }
+ })
+ const Comp = defineCustomElement(Comp1Vue)
+ expectType<VueElementConstructor>(Comp)
+
+ expectType<string | undefined>(new Comp().a)
+ })
+})
ComponentOptionsWithObjectProps,
ComponentOptionsWithoutProps,
ComponentPropsOptions,
- ComponentPublicInstance,
ComputedOptions,
EmitsOptions,
MethodOptions,
ConcreteComponent,
ComponentOptions,
ComponentInjectOptions,
- SlotsType
+ SlotsType,
+ DefineComponent
} from '@vue/runtime-core'
import { camelize, extend, hyphenate, isArray, toNumber } from '@vue/shared'
import { hydrate, render } from '.'
// overload 5: defining a custom element from the returned value of
// `defineComponent`
-export function defineCustomElement(options: {
- new (...args: any[]): ComponentPublicInstance
-}): VueElementConstructor
+export function defineCustomElement<P>(
+ options: DefineComponent<P, any, any, any>
+): VueElementConstructor<ExtractPropTypes<P>>
/*! #__NO_SIDE_EFFECTS__ */
export function defineCustomElement(