Skip to content

Commit 74c2a91

Browse files
committed
test: add
1 parent 29bc6b1 commit 74c2a91

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,24 @@ return { a, props, emit }
739739
}"
740740
`;
741741

742+
exports[`SFC compile <script setup> > defineProps/defineEmits in multi-variable declaration fix #7422 1`] = `
743+
"export default {
744+
props: ['item'],
745+
emits: ['foo'],
746+
setup(__props, { expose, emit: emits }) {
747+
expose();
748+
749+
const props = __props;
750+
751+
const a = 0,
752+
b = 0;
753+
754+
return { props, emits, a, b }
755+
}
756+
757+
}"
758+
`;
759+
742760
exports[`SFC compile <script setup> > dev mode import usage check > TS annotations 1`] = `
743761
"import { defineComponent as _defineComponent } from 'vue'
744762
import { Foo, Bar, Baz, Qux, Fred } from './x'

packages/compiler-sfc/__tests__/compileScript.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ const myEmit = defineEmits(['foo', 'bar'])
160160
expect(content).toMatch(`emits: ['a'],`)
161161
})
162162

163+
// #7422
164+
test('defineProps/defineEmits in multi-variable declaration fix #7422', () => {
165+
const { content } = compile(`
166+
<script setup>
167+
const props = defineProps(['item']),
168+
emits = defineEmits(['foo']),
169+
a = 0,
170+
b = 0;
171+
</script>
172+
`)
173+
assertCode(content)
174+
expect(content).toMatch(`props: ['item'],`)
175+
expect(content).toMatch(`emits: ['foo'],`)
176+
expect(content).toMatch(`const a = 0,`)
177+
expect(content).toMatch(`b = 0;`)
178+
})
179+
163180
test('defineProps/defineEmits in multi-variable declaration (full removal)', () => {
164181
const { content } = compile(`
165182
<script setup>

0 commit comments

Comments
 (0)