fix(types): defineEmits w/ interface declaration (#12343)

close #8457
This commit is contained in:
edison 2024-11-15 10:46:59 +08:00 committed by GitHub
parent 660132df6c
commit 1022eabaa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -306,6 +306,14 @@ describe('defineEmits w/ type declaration', () => {
emit2('baz')
})
describe('defineEmits w/ interface declaration', () => {
interface Emits {
foo: [value: string]
}
const emit = defineEmits<Emits>()
emit('foo', 'hi')
})
describe('defineEmits w/ alt type declaration', () => {
const emit = defineEmits<{
foo: [id: string]

View File

@ -149,9 +149,7 @@ export function defineEmits() {
return null as any
}
export type ComponentTypeEmits =
| ((...args: any[]) => any)
| Record<string, any[]>
export type ComponentTypeEmits = ((...args: any[]) => any) | Record<string, any>
type RecordToUnion<T extends Record<string, any>> = T[keyof T]