Skip to content

Commit

Permalink
fix(types): defineEmits w/ interface declaration (#12343)
Browse files Browse the repository at this point in the history
close #8457
  • Loading branch information
edison1105 authored Nov 15, 2024
1 parent 660132d commit 1022eab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages-private/dts-test/setupHelpers.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 1 addition & 3 deletions packages/runtime-core/src/apiSetupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit 1022eab

Please sign in to comment.