1
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
3
+ exports [` <script setup > ref sugar $computed declaration 1`] = `
4
+ "import { computed as _computed } from 'vue'
5
+
6
+ export default {
7
+ setup (__props , { expose }) {
8
+ expose()
9
+
10
+ const a = _computed(() => 1)
11
+
12
+ return { a }
13
+ }
14
+
15
+ } "
16
+ `;
17
+
18
+ exports[`<script setup > ref sugar $raw 1`] = `
19
+ "import { ref as _ref } from 'vue'
20
+
21
+ export default {
22
+ setup (__props , { expose }) {
23
+ expose()
24
+
25
+ let a = _ref(1)
26
+ const b = (a )
27
+ const c = ({ a })
28
+ callExternal((a ))
29
+
30
+ return { a , b , c }
31
+ }
32
+
33
+ } "
34
+ `;
35
+
36
+ exports[`<script setup > ref sugar $ref declarations 1`] = `
37
+ "import { ref as _ref } from 'vue'
38
+
39
+ export default {
40
+ setup (__props , { expose }) {
41
+ expose()
42
+
43
+ let foo = _ref()
44
+ let a = _ref(1)
45
+ let b = _ref({
46
+ count : 0
47
+ })
48
+ let c = () => {}
49
+ let d
50
+
51
+ return { foo , a , b , c , d }
52
+ }
53
+
54
+ }"
55
+ `;
56
+
3
57
exports[`<script setup > ref sugar accessing ref binding 1`] = `
4
58
"import { ref as _ref } from 'vue'
5
59
6
60
export default {
7
61
setup (__props , { expose }) {
8
62
expose()
9
63
10
- const a = _ref(1)
64
+ let a = _ref(1)
11
65
console.log(a .value )
12
66
function get() {
13
67
return a .value + 1
@@ -26,7 +80,7 @@ export default {
26
80
setup (__props , { expose }) {
27
81
expose()
28
82
29
- const n = _ref(1), [__a , __b = 1, ... __c ] = useFoo ()
83
+ let n = _ref(1), [__a , __b = 1, ... __c ] = ( useFoo () )
30
84
const a = _ref (__a );
31
85
const b = _ref (__b );
32
86
const c = _ref (__c );
@@ -38,35 +92,29 @@ return { n, a, b, c }
38
92
} "
39
93
`;
40
94
41
- exports[`<script setup > ref sugar convert ref declarations 1`] = `
42
- "import { ref as _ref } from 'vue'
95
+ exports[`<script setup > ref sugar mixing $ ref & $computed declarations 1`] = `
96
+ "import { ref as _ref , computed as _computed } from 'vue'
43
97
44
98
export default {
45
99
setup (__props , { expose }) {
46
100
expose()
47
101
48
- const foo = _ref()
49
- const a = _ref(1)
50
- const b = _ref({
51
- count : 0
52
- })
53
- let c = () => {}
54
- let d
102
+ let a = _ref(1), b = _computed(() => a.value + 1)
55
103
56
- return { foo , a , b , c , d }
104
+ return { a , b }
57
105
}
58
106
59
107
} "
60
108
`;
61
109
62
- exports[`<script setup > ref sugar multi ref declarations 1`] = `
110
+ exports[`<script setup > ref sugar multi $ ref declarations 1`] = `
63
111
"import { ref as _ref } from 'vue'
64
112
65
113
export default {
66
114
setup (__props , { expose }) {
67
115
expose()
68
116
69
- const a = _ref(1), b = _ref(2), c = _ref({
117
+ let a = _ref(1), b = _ref(2), c = _ref({
70
118
count : 0
71
119
})
72
120
@@ -83,8 +131,8 @@ export default {
83
131
setup (__props , { expose }) {
84
132
expose()
85
133
86
- const a = _ref(1)
87
- const b = _ref({ count : 0 })
134
+ let a = _ref(1)
135
+ let b = _ref({ count : 0 })
88
136
function inc() {
89
137
a .value ++
90
138
a .value = a .value + 1
@@ -107,9 +155,9 @@ export default {
107
155
setup (__props , { expose }) {
108
156
expose()
109
157
110
- const [{ a : { b : __b }}] = useFoo()
158
+ let [{ a : { b : __b }}] = ( useFoo () )
111
159
const b = _ref(__b );
112
- const { c: [__d , __e ] } = useBar ()
160
+ let { c: [__d , __e ] } = ( useBar () )
113
161
const d = _ref (__d );
114
162
const e = _ref (__e );
115
163
console .log (b .value , d .value , e .value )
@@ -127,13 +175,13 @@ export default {
127
175
setup (__props , { expose }) {
128
176
expose()
129
177
130
- const n = _ref(1), { a: __a , b: __c , d: __d = 1 , e: __f = 2 , ... __g } = useFoo ()
178
+ let n = _ref(1), { a: __a , b: __c , d: __d = 1 , e: __f = 2 , ... __g } = ( useFoo () )
131
179
const a = _ref (__a );
132
180
const c = _ref (__c );
133
181
const d = _ref (__d );
134
182
const f = _ref (__f );
135
183
const g = _ref (__g );
136
- const { foo: __foo } = useSomthing (() => 1 );
184
+ let { foo: __foo } = ( useSomthing (() => 1 ) );
137
185
const foo = _ref (__foo );
138
186
console .log (n .value , a .value , c .value , d .value , f .value , g .value , foo .value )
139
187
@@ -143,40 +191,23 @@ return { n, a, c, d, f, g, foo }
143
191
}"
144
192
`;
145
193
146
- exports[`<script setup > ref sugar should not convert non ref labels 1`] = `
147
- "export default {
148
- setup (__props , { expose }) {
149
- expose()
150
-
151
- foo: a = 1, b = 2, c = {
152
- count: 0
153
- }
154
-
155
- return { }
156
- }
157
-
158
- }"
159
- `;
160
-
161
194
exports[`<script setup > ref sugar should not rewrite scope variable 1`] = `
162
195
"import { ref as _ref } from 'vue'
163
196
164
197
export default {
165
198
setup (__props , { expose }) {
166
199
expose()
167
200
168
- const a = _ref(1)
169
- const b = _ref(1)
170
- const d = _ref(1)
201
+ let a = _ref(1)
202
+ let b = _ref(1)
203
+ let d = _ref(1)
171
204
const e = 1
172
205
function test() {
173
206
const a = 2
174
207
console .log (a )
175
208
console .log (b .value )
176
209
let c = { c: 3 }
177
210
console .log (c )
178
- let $d
179
- console .log ($d )
180
211
console .log (d .value )
181
212
console .log (e )
182
213
}
@@ -200,7 +231,7 @@ export default _defineComponent({
200
231
201
232
const props = __props
202
233
203
- const ids = _ref([])
234
+ let ids = _ref([])
204
235
205
236
return { props , ids }
206
237
}
@@ -215,7 +246,7 @@ export default {
215
246
setup (__props , { expose }) {
216
247
expose()
217
248
218
- const a = _ref(1)
249
+ let a = _ref(1)
219
250
const b = { a : a .value }
220
251
function test() {
221
252
const { a } = b
0 commit comments