`;
exports[`array destructure 1`] = `
-"import { ref as _ref } from 'vue'
+"import { ref as _ref, shallowRef as _shallowRef } from 'vue'
let n = _ref(1), [__a, __b = 1, ...__c] = (useFoo())
-const a = _ref(__a);
-const b = _ref(__b);
-const c = _ref(__c);
+const a = _shallowRef(__a);
+const b = _shallowRef(__b);
+const c = _shallowRef(__c);
console.log(n.value, a.value, b.value, c.value)
"
`;
`;
exports[`nested destructure 1`] = `
-"import { ref as _ref } from 'vue'
+"import { shallowRef as _shallowRef } from 'vue'
let [{ a: { b: __b }}] = (useFoo())
-const b = _ref(__b);
+const b = _shallowRef(__b);
let { c: [__d, __e] } = (useBar())
-const d = _ref(__d);
-const e = _ref(__e);
+const d = _shallowRef(__d);
+const e = _shallowRef(__e);
console.log(b.value, d.value, e.value)
"
`;
`;
exports[`object destructure 1`] = `
-"import { ref as _ref } from 'vue'
+"import { ref as _ref, shallowRef as _shallowRef } from 'vue'
let n = _ref(1), { a: __a, b: __c, d: __d = 1, e: __f = 2, ...__g } = (useFoo())
-const a = _ref(__a);
-const c = _ref(__c);
-const d = _ref(__d);
-const f = _ref(__f);
-const g = _ref(__g);
+const a = _shallowRef(__a);
+const c = _shallowRef(__c);
+const d = _shallowRef(__d);
+const f = _shallowRef(__f);
+const g = _shallowRef(__g);
let { foo: __foo } = (useSomthing(() => 1));
-const foo = _ref(__foo);
+const foo = _shallowRef(__foo);
console.log(n.value, a.value, c.value, d.value, f.value, g.value, foo.value)
"
`;
`let n = _ref(1), { a: __a, b: __c, d: __d = 1, e: __f = 2, ...__g } = (useFoo())`
)
expect(code).toMatch(`let { foo: __foo } = (useSomthing(() => 1))`)
- expect(code).toMatch(`\nconst a = _ref(__a);`)
- expect(code).not.toMatch(`\nconst b = _ref(__b);`)
- expect(code).toMatch(`\nconst c = _ref(__c);`)
- expect(code).toMatch(`\nconst d = _ref(__d);`)
- expect(code).not.toMatch(`\nconst e = _ref(__e);`)
- expect(code).toMatch(`\nconst f = _ref(__f);`)
- expect(code).toMatch(`\nconst g = _ref(__g);`)
- expect(code).toMatch(`\nconst foo = _ref(__foo);`)
+ expect(code).toMatch(`\nconst a = _shallowRef(__a);`)
+ expect(code).not.toMatch(`\nconst b = _shallowRef(__b);`)
+ expect(code).toMatch(`\nconst c = _shallowRef(__c);`)
+ expect(code).toMatch(`\nconst d = _shallowRef(__d);`)
+ expect(code).not.toMatch(`\nconst e = _shallowRef(__e);`)
+ expect(code).toMatch(`\nconst f = _shallowRef(__f);`)
+ expect(code).toMatch(`\nconst g = _shallowRef(__g);`)
+ expect(code).toMatch(`\nconst foo = _shallowRef(__foo);`)
expect(code).toMatch(
`console.log(n.value, a.value, c.value, d.value, f.value, g.value, foo.value)`
)
console.log(n, a, b, c)
`)
expect(code).toMatch(`let n = _ref(1), [__a, __b = 1, ...__c] = (useFoo())`)
- expect(code).toMatch(`\nconst a = _ref(__a);`)
- expect(code).toMatch(`\nconst b = _ref(__b);`)
- expect(code).toMatch(`\nconst c = _ref(__c);`)
+ expect(code).toMatch(`\nconst a = _shallowRef(__a);`)
+ expect(code).toMatch(`\nconst b = _shallowRef(__b);`)
+ expect(code).toMatch(`\nconst c = _shallowRef(__c);`)
expect(code).toMatch(`console.log(n.value, a.value, b.value, c.value)`)
expect(rootVars).toStrictEqual(['n', 'a', 'b', 'c'])
assertCode(code)
`)
expect(code).toMatch(`let [{ a: { b: __b }}] = (useFoo())`)
expect(code).toMatch(`let { c: [__d, __e] } = (useBar())`)
- expect(code).not.toMatch(`\nconst a = _ref(__a);`)
- expect(code).not.toMatch(`\nconst c = _ref(__c);`)
- expect(code).toMatch(`\nconst b = _ref(__b);`)
- expect(code).toMatch(`\nconst d = _ref(__d);`)
- expect(code).toMatch(`\nconst e = _ref(__e);`)
+ expect(code).not.toMatch(`\nconst a = _shallowRef(__a);`)
+ expect(code).not.toMatch(`\nconst c = _shallowRef(__c);`)
+ expect(code).toMatch(`\nconst b = _shallowRef(__b);`)
+ expect(code).toMatch(`\nconst d = _shallowRef(__d);`)
+ expect(code).toMatch(`\nconst e = _shallowRef(__e);`)
expect(rootVars).toStrictEqual(['b', 'd', 'e'])
assertCode(code)
})