]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: add test for defineComponent function syntax with object emits
authorEvan You <yyx990803@gmail.com>
Tue, 28 Mar 2023 00:57:56 +0000 (08:57 +0800)
committerEvan You <yyx990803@gmail.com>
Tue, 28 Mar 2023 00:57:56 +0000 (08:57 +0800)
packages/dts-test/defineComponent.test-d.tsx

index 1b981a87cb067d6d5023c9b461fe5b87d9f4d707..3aec37e97b6aa32bf2dafaddd569aaad1e3b881a 100644 (file)
@@ -1300,6 +1300,22 @@ describe('function syntax w/ emits', () => {
   expectType<JSX.Element>(<Foo msg="hi" onFoo={() => {}} />)
   // @ts-expect-error
   expectType<JSX.Element>(<Foo msg="hi" onBar={() => {}} />)
+
+  defineComponent(
+    (props: { msg: string }, ctx) => {
+      ctx.emit('foo', 'hi')
+      // @ts-expect-error
+      ctx.emit('foo')
+      // @ts-expect-error
+      ctx.emit('bar')
+      return () => {}
+    },
+    {
+      emits: {
+        foo: (a: string) => true
+      }
+    }
+  )
 })
 
 describe('function syntax w/ runtime props', () => {