Просмотр исходного кода

test: add test for defineComponent function syntax with object emits

Evan You 3 лет назад
Родитель
Сommit
e3de9a6911
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      packages/dts-test/defineComponent.test-d.tsx

+ 16 - 0
packages/dts-test/defineComponent.test-d.tsx

@@ -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', () => {