Skip to content

Commit 46658f8

Browse files
committed
test: add
1 parent 86c119b commit 46658f8

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
@@ -754,6 +754,24 @@ return { a, props, emit }
754754
}"
755755
`;
756756

757+
exports[`SFC compile <script setup> > defineProps/defineEmits in multi-variable declaration fix #7422 1`] = `
758+
"export default {
759+
props: ['item'],
760+
emits: ['foo'],
761+
setup(__props, { expose, emit: emits }) {
762+
expose();
763+
764+
const props = __props;
765+
766+
const a = 0,
767+
b = 0;
768+
769+
return { props, emits, a, b }
770+
}
771+
772+
}"
773+
`;
774+
757775
exports[`SFC compile <script setup> > dev mode import usage check > TS annotations 1`] = `
758776
"import { defineComponent as _defineComponent } from 'vue'
759777
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)