|
|
@@ -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)
|