@@ -138,14 +138,10 @@ export function VariableDeclaration(node, context) {
138
138
} ;
139
139
140
140
if ( declarator . id . type === 'Identifier' ) {
141
+ const expression = /** @type {Expression } */ ( context . visit ( value ) ) ;
142
+
141
143
declarations . push (
142
- b . declarator (
143
- declarator . id ,
144
- create_state_declarator (
145
- declarator . id ,
146
- /** @type {Expression } */ ( context . visit ( value ) )
147
- )
148
- )
144
+ b . declarator ( declarator . id , create_state_declarator ( declarator . id , expression ) )
149
145
) ;
150
146
} else {
151
147
const tmp = b . id ( context . state . scope . generate ( 'tmp' ) ) ;
@@ -157,10 +153,8 @@ export function VariableDeclaration(node, context) {
157
153
id . name = context . state . scope . generate ( '$$array' ) ;
158
154
context . state . transform [ id . name ] = { read : get_value } ;
159
155
160
- return b . declarator (
161
- id ,
162
- b . call ( '$.derived' , /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) )
163
- ) ;
156
+ const expression = /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) ;
157
+ return b . declarator ( id , b . call ( '$.derived' , expression ) ) ;
164
158
} ) ,
165
159
...paths . map ( ( path ) => {
166
160
const value = /** @type {Expression } */ ( context . visit ( path . expression ) ) ;
@@ -205,12 +199,8 @@ export function VariableDeclaration(node, context) {
205
199
id . name = context . state . scope . generate ( '$$array' ) ;
206
200
context . state . transform [ id . name ] = { read : get_value } ;
207
201
208
- declarations . push (
209
- b . declarator (
210
- id ,
211
- b . call ( '$.derived' , /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) )
212
- )
213
- ) ;
202
+ const expression = /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) ;
203
+ declarations . push ( b . declarator ( id , b . call ( '$.derived' , expression ) ) ) ;
214
204
}
215
205
216
206
for ( const path of paths ) {
@@ -261,12 +251,8 @@ export function VariableDeclaration(node, context) {
261
251
id . name = context . state . scope . generate ( '$$array' ) ;
262
252
context . state . transform [ id . name ] = { read : get_value } ;
263
253
264
- declarations . push (
265
- b . declarator (
266
- id ,
267
- b . call ( '$.derived' , /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) )
268
- )
269
- ) ;
254
+ const expression = /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) ;
255
+ declarations . push ( b . declarator ( id , b . call ( '$.derived' , expression ) ) ) ;
270
256
}
271
257
272
258
for ( const path of paths ) {
@@ -349,10 +335,8 @@ function create_state_declarators(declarator, context, value) {
349
335
id . name = context . state . scope . generate ( '$$array' ) ;
350
336
context . state . transform [ id . name ] = { read : get_value } ;
351
337
352
- return b . declarator (
353
- id ,
354
- b . call ( '$.derived' , /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) )
355
- ) ;
338
+ const expression = /** @type {Expression } */ ( context . visit ( b . thunk ( value ) ) ) ;
339
+ return b . declarator ( id , b . call ( '$.derived' , expression ) ) ;
356
340
} ) ,
357
341
...paths . map ( ( path ) => {
358
342
const value = /** @type {Expression } */ ( context . visit ( path . expression ) ) ;
0 commit comments