]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(types): defineEmits w/ interface declaration (#12343)
authoredison <daiwei521@126.com>
Fri, 15 Nov 2024 02:46:59 +0000 (10:46 +0800)
committerGitHub <noreply@github.com>
Fri, 15 Nov 2024 02:46:59 +0000 (10:46 +0800)
close #8457

packages-private/dts-test/setupHelpers.test-d.ts
packages/runtime-core/src/apiSetupHelpers.ts

index 7b5d6f147f08ab5cc3a8c8b58995af255741df32..656f1da79f2eb7c95a6977f5bb77588e8accf8e7 100644 (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]
index 54712c6807a606f05daa729c7c56bf52623d31dd..2ddaeb509ad7c2a418e6f852f97924ba7fddec3a 100644 (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]