fix(compiler-sfc/reactivity-transform): fix edge case where normal script has ref macros but script setup does not
This commit is contained in:
@@ -71,6 +71,23 @@ exports[`sfc ref transform usage in normal <script> 1`] = `
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`sfc ref transform usage with normal <script> (has macro usage) + <script setup> (no macro usage) 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
let data = _ref()
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose();
|
||||
|
||||
console.log(data.value)
|
||||
|
||||
return { data }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`sfc ref transform usage with normal <script> + <script setup> 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
|
||||
@@ -146,6 +146,19 @@ describe('sfc ref transform', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('usage with normal <script> (has macro usage) + <script setup> (no macro usage)', () => {
|
||||
const { content } = compileWithReactivityTransform(`
|
||||
<script>
|
||||
let data = $ref()
|
||||
</script>
|
||||
<script setup>
|
||||
console.log(data)
|
||||
</script>
|
||||
`)
|
||||
expect(content).toMatch(`console.log(data.value)`)
|
||||
assertCode(content)
|
||||
})
|
||||
|
||||
describe('errors', () => {
|
||||
test('defineProps/Emit() referencing ref declarations', () => {
|
||||
expect(() =>
|
||||
|
||||
Reference in New Issue
Block a user