2021-07-06 02:41:53 +08:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
exports[`<script setup> ref sugar $computed declaration 1`] = `
|
|
|
|
"import { computed as _computed } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
|
|
|
const a = _computed(() => 1)
|
|
|
|
|
|
|
|
return { a }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar $raw 1`] = `
|
|
|
|
"import { ref as _ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
|
|
|
let a = _ref(1)
|
|
|
|
const b = (a)
|
|
|
|
const c = ({ a })
|
|
|
|
callExternal((a))
|
|
|
|
|
|
|
|
return { a, b, c }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar $ref declarations 1`] = `
|
|
|
|
"import { ref as _ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
|
|
|
let foo = _ref()
|
|
|
|
let a = _ref(1)
|
|
|
|
let b = _ref({
|
|
|
|
count: 0
|
|
|
|
})
|
|
|
|
let c = () => {}
|
|
|
|
let d
|
|
|
|
|
|
|
|
return { foo, a, b, c, d }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
2021-07-06 02:41:53 +08:00
|
|
|
exports[`<script setup> ref sugar accessing ref binding 1`] = `
|
|
|
|
"import { ref as _ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let a = _ref(1)
|
2021-07-06 02:41:53 +08:00
|
|
|
console.log(a.value)
|
|
|
|
function get() {
|
|
|
|
return a.value + 1
|
|
|
|
}
|
|
|
|
|
|
|
|
return { a, get }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar array destructure 1`] = `
|
2021-08-05 03:39:23 +08:00
|
|
|
"import { ref as _ref, shallowRef as _shallowRef } from 'vue'
|
2021-07-06 02:41:53 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let n = _ref(1), [__a, __b = 1, ...__c] = (useFoo())
|
2021-08-05 03:39:23 +08:00
|
|
|
const a = _shallowRef(__a);
|
|
|
|
const b = _shallowRef(__b);
|
|
|
|
const c = _shallowRef(__c);
|
2021-07-06 02:41:53 +08:00
|
|
|
console.log(n.value, a.value, b.value, c.value)
|
|
|
|
|
|
|
|
return { n, a, b, c }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
2021-08-07 00:55:48 +08:00
|
|
|
exports[`<script setup> ref sugar handle TS casting syntax 1`] = `
|
|
|
|
"import { ref as _ref, defineComponent as _defineComponent } from 'vue'
|
|
|
|
|
|
|
|
export default _defineComponent({
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-08-07 01:01:39 +08:00
|
|
|
let a = _ref(1)
|
|
|
|
console.log(a.value!)
|
|
|
|
console.log(a.value! + 1)
|
|
|
|
console.log(a.value as number)
|
|
|
|
console.log((a.value as number) + 1)
|
|
|
|
console.log(<number>a.value)
|
|
|
|
console.log(<number>a.value + 1)
|
|
|
|
console.log(a.value! + (a.value as number))
|
|
|
|
console.log(a.value! + <number>a.value)
|
|
|
|
console.log((a.value as number) + <number>a.value)
|
2021-08-07 00:55:48 +08:00
|
|
|
|
2021-08-07 01:01:39 +08:00
|
|
|
return { a }
|
2021-08-07 00:55:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
})"
|
|
|
|
`;
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
exports[`<script setup> ref sugar mixing $ref & $computed declarations 1`] = `
|
|
|
|
"import { ref as _ref, computed as _computed } from 'vue'
|
2021-07-06 02:41:53 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let a = _ref(1), b = _computed(() => a.value + 1)
|
2021-07-06 02:41:53 +08:00
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
return { a, b }
|
2021-07-06 02:41:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
exports[`<script setup> ref sugar multi $ref declarations 1`] = `
|
2021-07-06 02:41:53 +08:00
|
|
|
"import { ref as _ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let a = _ref(1), b = _ref(2), c = _ref({
|
2021-07-06 02:41:53 +08:00
|
|
|
count: 0
|
|
|
|
})
|
|
|
|
|
|
|
|
return { a, b, c }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar mutating ref binding 1`] = `
|
|
|
|
"import { ref as _ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let a = _ref(1)
|
|
|
|
let b = _ref({ count: 0 })
|
2021-07-06 02:41:53 +08:00
|
|
|
function inc() {
|
|
|
|
a.value++
|
|
|
|
a.value = a.value + 1
|
|
|
|
b.value.count++
|
|
|
|
b.value.count = b.value.count + 1
|
|
|
|
;({ a: a.value } = { a: 2 })
|
|
|
|
;[a.value] = [1]
|
|
|
|
}
|
|
|
|
|
|
|
|
return { a, b, inc }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar nested destructure 1`] = `
|
2021-08-05 03:39:23 +08:00
|
|
|
"import { shallowRef as _shallowRef } from 'vue'
|
2021-07-06 02:41:53 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let [{ a: { b: __b }}] = (useFoo())
|
2021-08-05 03:39:23 +08:00
|
|
|
const b = _shallowRef(__b);
|
2021-07-15 03:35:34 +08:00
|
|
|
let { c: [__d, __e] } = (useBar())
|
2021-08-05 03:39:23 +08:00
|
|
|
const d = _shallowRef(__d);
|
|
|
|
const e = _shallowRef(__e);
|
2021-07-06 02:41:53 +08:00
|
|
|
console.log(b.value, d.value, e.value)
|
|
|
|
|
|
|
|
return { b, d, e }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar object destructure 1`] = `
|
2021-08-05 03:39:23 +08:00
|
|
|
"import { ref as _ref, shallowRef as _shallowRef } from 'vue'
|
2021-07-06 02:41:53 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let n = _ref(1), { a: __a, b: __c, d: __d = 1, e: __f = 2, ...__g } = (useFoo())
|
2021-08-05 03:39:23 +08:00
|
|
|
const a = _shallowRef(__a);
|
|
|
|
const c = _shallowRef(__c);
|
|
|
|
const d = _shallowRef(__d);
|
|
|
|
const f = _shallowRef(__f);
|
|
|
|
const g = _shallowRef(__g);
|
2021-07-15 03:35:34 +08:00
|
|
|
let { foo: __foo } = (useSomthing(() => 1));
|
2021-08-05 03:39:23 +08:00
|
|
|
const foo = _shallowRef(__foo);
|
2021-07-06 02:41:53 +08:00
|
|
|
console.log(n.value, a.value, c.value, d.value, f.value, g.value, foo.value)
|
|
|
|
|
|
|
|
return { n, a, c, d, f, g, foo }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar should not rewrite scope variable 1`] = `
|
|
|
|
"import { ref as _ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let a = _ref(1)
|
|
|
|
let b = _ref(1)
|
|
|
|
let d = _ref(1)
|
2021-07-06 02:41:53 +08:00
|
|
|
const e = 1
|
|
|
|
function test() {
|
|
|
|
const a = 2
|
|
|
|
console.log(a)
|
|
|
|
console.log(b.value)
|
|
|
|
let c = { c: 3 }
|
|
|
|
console.log(c)
|
|
|
|
console.log(d.value)
|
|
|
|
console.log(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
return { a, b, d, e, test }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar should not rewrite type identifiers 1`] = `
|
|
|
|
"import { ref as _ref, defineComponent as _defineComponent } from 'vue'
|
|
|
|
|
|
|
|
export default _defineComponent({
|
|
|
|
props: {
|
|
|
|
msg: { type: String, required: true },
|
|
|
|
ids: { type: Array, required: false }
|
|
|
|
} as unknown as undefined,
|
|
|
|
setup(__props: {msg: string; ids?: string[]}, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
|
|
|
const props = __props
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let ids = _ref([])
|
2021-07-06 02:41:53 +08:00
|
|
|
|
|
|
|
return { props, ids }
|
|
|
|
}
|
|
|
|
|
|
|
|
})"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`<script setup> ref sugar using ref binding in property shorthand 1`] = `
|
|
|
|
"import { ref as _ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup(__props, { expose }) {
|
|
|
|
expose()
|
|
|
|
|
2021-07-15 03:35:34 +08:00
|
|
|
let a = _ref(1)
|
2021-07-06 02:41:53 +08:00
|
|
|
const b = { a: a.value }
|
|
|
|
function test() {
|
|
|
|
const { a } = b
|
|
|
|
}
|
|
|
|
|
|
|
|
return { a, b, test }
|
|
|
|
}
|
|
|
|
|
|
|
|
}"
|
|
|
|
`;
|