fix(ref-transform): should transform $ref when used with generic arguments (#4446)

fix #4442
This commit is contained in:
edison
2021-09-02 04:55:30 +08:00
committed by GitHub
parent a6e6253319
commit 33cf6c8866
3 changed files with 30 additions and 1 deletions

View File

@@ -99,6 +99,19 @@ describe('sfc ref transform', () => {
assertCode(content)
})
test('usage /w typescript', () => {
const { content } = compileWithRefTransform(`
<script setup lang="ts">
let msg = $ref<string | number>('foo');
let bar = $ref <string | number>('bar');
</script>
`)
expect(content).toMatch(`import { ref as _ref`)
expect(content).toMatch(`let msg = _ref<string | number>('foo')`)
expect(content).toMatch(`let bar = _ref <string | number>('bar')`)
assertCode(content)
})
test('usage with normal <script> + <script setup>', () => {
const { content, bindings } = compileWithRefTransform(`<script>
let a = $ref(0)