fix(compiler-sfc): support proper type arguments for defineEmit helper
fix #2874
This commit is contained in:
@@ -532,6 +532,18 @@ const emit = defineEmit(['a', 'b'])
|
||||
|
||||
test('defineEmit w/ type (union)', () => {
|
||||
const type = `((e: 'foo' | 'bar') => void) | ((e: 'baz', id: number) => void)`
|
||||
expect(() =>
|
||||
compile(`
|
||||
<script setup lang="ts">
|
||||
import { defineEmit } from 'vue'
|
||||
const emit = defineEmit<${type}>()
|
||||
</script>
|
||||
`)
|
||||
).toThrow()
|
||||
})
|
||||
|
||||
test('defineEmit w/ type (type literal w/ call signatures)', () => {
|
||||
const type = `{(e: 'foo' | 'bar'): void; (e: 'baz', id: number): void;}`
|
||||
const { content } = compile(`
|
||||
<script setup lang="ts">
|
||||
import { defineEmit } from 'vue'
|
||||
|
||||
Reference in New Issue
Block a user