Skip to content

Commit

Permalink
test: add
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed May 12, 2023
1 parent 228b687 commit 0afb7b4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ export default /*#__PURE__*/_defineComponent({
return { emit }
}
})"
`;

exports[`defineEmits > w/ type (type references in union) 1`] = `
"import { defineComponent as _defineComponent } from 'vue'
type BaseEmit = \\"change\\"
type Emit = \\"some\\" | \\"emit\\" | BaseEmit
export default /*#__PURE__*/_defineComponent({
emits: [\\"some\\", \\"emit\\", \\"change\\", \\"another\\"],
setup(__props, { expose: __expose, emit }) {
__expose();
return { emit }
}
Expand Down
17 changes: 17 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript/defineEmits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ const emit = defineEmits(['a', 'b'])
assertCode(content)
})

// #7943
test('w/ type (type references in union)', () => {
const { content } = compile(`
<script setup lang="ts">
type BaseEmit = "change"
type Emit = "some" | "emit" | BaseEmit
const emit = defineEmits<{
(e: Emit): void;
(e: "another", val: string): void;
}>();
</script>
`)

expect(content).toMatch(`emits: ["some", "emit", "change", "another"]`)
assertCode(content)
})

describe('errors', () => {
test('w/ both type and non-type args', () => {
expect(() => {
Expand Down

0 comments on commit 0afb7b4

Please sign in to comment.