feat(sfc): make ref sugar disabled by default
This commit is contained in:
@@ -554,212 +554,6 @@ return () => {}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar accessing ref binding 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const a = _ref(1)
|
||||
console.log(a.value)
|
||||
function get() {
|
||||
return a.value + 1
|
||||
}
|
||||
|
||||
return { a, get }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar array destructure 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const n = _ref(1), [__a, __b = 1, ...__c] = useFoo()
|
||||
const a = _ref(__a);
|
||||
const b = _ref(__b);
|
||||
const c = _ref(__c);
|
||||
console.log(n.value, a.value, b.value, c.value)
|
||||
|
||||
return { n, a, b, c }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar convert ref declarations 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const foo = _ref()
|
||||
const a = _ref(1)
|
||||
const b = _ref({
|
||||
count: 0
|
||||
})
|
||||
let c = () => {}
|
||||
let d
|
||||
|
||||
return { foo, a, b, c, d }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar multi ref declarations 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const a = _ref(1), b = _ref(2), c = _ref({
|
||||
count: 0
|
||||
})
|
||||
|
||||
return { a, b, c }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar mutating ref binding 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const a = _ref(1)
|
||||
const b = _ref({ count: 0 })
|
||||
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[`SFC compile <script setup> ref: syntax sugar nested destructure 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const [{ a: { b: __b }}] = useFoo()
|
||||
const b = _ref(__b);
|
||||
const { c: [__d, __e] } = useBar()
|
||||
const d = _ref(__d);
|
||||
const e = _ref(__e);
|
||||
console.log(b.value, d.value, e.value)
|
||||
|
||||
return { b, d, e }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar object destructure 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const 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 { foo: __foo } = useSomthing(() => 1);
|
||||
const foo = _ref(__foo);
|
||||
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[`SFC compile <script setup> ref: syntax sugar should not convert non ref labels 1`] = `
|
||||
"export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
foo: a = 1, b = 2, c = {
|
||||
count: 0
|
||||
}
|
||||
|
||||
return { }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar should not rewrite scope variable 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const a = _ref(1)
|
||||
const b = _ref(1)
|
||||
const d = _ref(1)
|
||||
const e = 1
|
||||
function test() {
|
||||
const a = 2
|
||||
console.log(a)
|
||||
console.log(b.value)
|
||||
let c = { c: 3 }
|
||||
console.log(c)
|
||||
let $d
|
||||
console.log($d)
|
||||
console.log(d.value)
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
return { a, b, d, e, test }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> ref: syntax sugar using ref binding in property shorthand 1`] = `
|
||||
"import { ref as _ref } from 'vue'
|
||||
|
||||
export default {
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const a = _ref(1)
|
||||
const b = { a: a.value }
|
||||
function test() {
|
||||
const { a } = b
|
||||
}
|
||||
|
||||
return { a, b, test }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> should expose top level declarations 1`] = `
|
||||
"import { x } from './x'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user