Skip to content

Commit 1022eab

Browse files
authored
fix(types): defineEmits w/ interface declaration (#12343)
close #8457
1 parent 660132d commit 1022eab

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: packages-private/dts-test/setupHelpers.test-d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ describe('defineEmits w/ type declaration', () => {
306306
emit2('baz')
307307
})
308308

309+
describe('defineEmits w/ interface declaration', () => {
310+
interface Emits {
311+
foo: [value: string]
312+
}
313+
const emit = defineEmits<Emits>()
314+
emit('foo', 'hi')
315+
})
316+
309317
describe('defineEmits w/ alt type declaration', () => {
310318
const emit = defineEmits<{
311319
foo: [id: string]

Diff for: packages/runtime-core/src/apiSetupHelpers.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ export function defineEmits() {
149149
return null as any
150150
}
151151

152-
export type ComponentTypeEmits =
153-
| ((...args: any[]) => any)
154-
| Record<string, any[]>
152+
export type ComponentTypeEmits = ((...args: any[]) => any) | Record<string, any>
155153

156154
type RecordToUnion<T extends Record<string, any>> = T[keyof T]
157155

0 commit comments

Comments
 (0)