Commit 57b6335 1 parent ff6ec1d commit 57b6335 Copy full SHA for 57b6335
File tree 6 files changed +313
-1
lines changed
variables_reassignment_TSAsExpression
variables_reassignment_TSNonNullExpression
6 files changed +313
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/acorn-typescript ' : patch
3
+ ---
4
+
5
+ fix: allow type casts during reassignments
Original file line number Diff line number Diff line change @@ -2609,7 +2609,7 @@ export function tsPlugin(options?: {
2609
2609
}
2610
2610
2611
2611
checkLValSimple ( expr : any , bindingType : any = acornScope . BIND_NONE , checkClashes ?: any ) {
2612
- if ( expr . type === 'TSNonNullExpression' ) {
2612
+ if ( expr . type === 'TSNonNullExpression' || expr . type === 'TSAsExpression' ) {
2613
2613
expr = expr . expression ;
2614
2614
}
2615
2615
return super . checkLValSimple ( expr , bindingType , checkClashes ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Program" ,
3
+ "start" : 0 ,
4
+ "end" : 69 ,
5
+ "loc" : {
6
+ "start" : {
7
+ "line" : 1 ,
8
+ "column" : 0
9
+ },
10
+ "end" : {
11
+ "line" : 3 ,
12
+ "column" : 19
13
+ }
14
+ },
15
+ "body" : [
16
+ {
17
+ "type" : " VariableDeclaration" ,
18
+ "start" : 0 ,
19
+ "end" : 30 ,
20
+ "loc" : {
21
+ "start" : {
22
+ "line" : 1 ,
23
+ "column" : 0
24
+ },
25
+ "end" : {
26
+ "line" : 1 ,
27
+ "column" : 30
28
+ }
29
+ },
30
+ "declarations" : [
31
+ {
32
+ "type" : " VariableDeclarator" ,
33
+ "start" : 4 ,
34
+ "end" : 29 ,
35
+ "loc" : {
36
+ "start" : {
37
+ "line" : 1 ,
38
+ "column" : 4
39
+ },
40
+ "end" : {
41
+ "line" : 1 ,
42
+ "column" : 29
43
+ }
44
+ },
45
+ "id" : {
46
+ "type" : " Identifier" ,
47
+ "start" : 4 ,
48
+ "end" : 25 ,
49
+ "loc" : {
50
+ "start" : {
51
+ "line" : 1 ,
52
+ "column" : 4
53
+ },
54
+ "end" : {
55
+ "line" : 1 ,
56
+ "column" : 25
57
+ }
58
+ },
59
+ "name" : " a" ,
60
+ "typeAnnotation" : {
61
+ "type" : " TSTypeAnnotation" ,
62
+ "start" : 5 ,
63
+ "end" : 25 ,
64
+ "loc" : {
65
+ "start" : {
66
+ "line" : 1 ,
67
+ "column" : 5
68
+ },
69
+ "end" : {
70
+ "line" : 1 ,
71
+ "column" : 25
72
+ }
73
+ },
74
+ "typeAnnotation" : {
75
+ "type" : " TSUnionType" ,
76
+ "start" : 7 ,
77
+ "end" : 25 ,
78
+ "loc" : {
79
+ "start" : {
80
+ "line" : 1 ,
81
+ "column" : 7
82
+ },
83
+ "end" : {
84
+ "line" : 1 ,
85
+ "column" : 25
86
+ }
87
+ },
88
+ "types" : [
89
+ {
90
+ "type" : " TSNumberKeyword" ,
91
+ "start" : 7 ,
92
+ "end" : 13 ,
93
+ "loc" : {
94
+ "start" : {
95
+ "line" : 1 ,
96
+ "column" : 7
97
+ },
98
+ "end" : {
99
+ "line" : 1 ,
100
+ "column" : 13
101
+ }
102
+ }
103
+ },
104
+ {
105
+ "type" : " TSUndefinedKeyword" ,
106
+ "start" : 16 ,
107
+ "end" : 25 ,
108
+ "loc" : {
109
+ "start" : {
110
+ "line" : 1 ,
111
+ "column" : 16
112
+ },
113
+ "end" : {
114
+ "line" : 1 ,
115
+ "column" : 25
116
+ }
117
+ }
118
+ }
119
+ ]
120
+ }
121
+ }
122
+ },
123
+ "init" : {
124
+ "type" : " Literal" ,
125
+ "start" : 28 ,
126
+ "end" : 29 ,
127
+ "loc" : {
128
+ "start" : {
129
+ "line" : 1 ,
130
+ "column" : 28
131
+ },
132
+ "end" : {
133
+ "line" : 1 ,
134
+ "column" : 29
135
+ }
136
+ },
137
+ "value" : 1 ,
138
+ "raw" : " 1"
139
+ }
140
+ }
141
+ ],
142
+ "kind" : " let"
143
+ },
144
+ {
145
+ "type" : " ExpressionStatement" ,
146
+ "start" : 31 ,
147
+ "end" : 49 ,
148
+ "loc" : {
149
+ "start" : {
150
+ "line" : 2 ,
151
+ "column" : 0
152
+ },
153
+ "end" : {
154
+ "line" : 2 ,
155
+ "column" : 18
156
+ }
157
+ },
158
+ "expression" : {
159
+ "type" : " AssignmentExpression" ,
160
+ "start" : 31 ,
161
+ "end" : 48 ,
162
+ "loc" : {
163
+ "start" : {
164
+ "line" : 2 ,
165
+ "column" : 0
166
+ },
167
+ "end" : {
168
+ "line" : 2 ,
169
+ "column" : 17
170
+ }
171
+ },
172
+ "operator" : " =" ,
173
+ "left" : {
174
+ "type" : " Identifier" ,
175
+ "start" : 32 ,
176
+ "end" : 33 ,
177
+ "loc" : {
178
+ "start" : {
179
+ "line" : 2 ,
180
+ "column" : 1
181
+ },
182
+ "end" : {
183
+ "line" : 2 ,
184
+ "column" : 2
185
+ }
186
+ },
187
+ "name" : " a"
188
+ },
189
+ "right" : {
190
+ "type" : " Literal" ,
191
+ "start" : 47 ,
192
+ "end" : 48 ,
193
+ "loc" : {
194
+ "start" : {
195
+ "line" : 2 ,
196
+ "column" : 16
197
+ },
198
+ "end" : {
199
+ "line" : 2 ,
200
+ "column" : 17
201
+ }
202
+ },
203
+ "value" : 2 ,
204
+ "raw" : " 2"
205
+ }
206
+ }
207
+ },
208
+ {
209
+ "type" : " ExpressionStatement" ,
210
+ "start" : 50 ,
211
+ "end" : 69 ,
212
+ "loc" : {
213
+ "start" : {
214
+ "line" : 3 ,
215
+ "column" : 0
216
+ },
217
+ "end" : {
218
+ "line" : 3 ,
219
+ "column" : 19
220
+ }
221
+ },
222
+ "expression" : {
223
+ "type" : " AssignmentExpression" ,
224
+ "start" : 50 ,
225
+ "end" : 68 ,
226
+ "loc" : {
227
+ "start" : {
228
+ "line" : 3 ,
229
+ "column" : 0
230
+ },
231
+ "end" : {
232
+ "line" : 3 ,
233
+ "column" : 18
234
+ }
235
+ },
236
+ "operator" : " +=" ,
237
+ "left" : {
238
+ "type" : " TSAsExpression" ,
239
+ "start" : 51 ,
240
+ "end" : 62 ,
241
+ "loc" : {
242
+ "start" : {
243
+ "line" : 3 ,
244
+ "column" : 1
245
+ },
246
+ "end" : {
247
+ "line" : 3 ,
248
+ "column" : 12
249
+ }
250
+ },
251
+ "expression" : {
252
+ "type" : " Identifier" ,
253
+ "start" : 51 ,
254
+ "end" : 52 ,
255
+ "loc" : {
256
+ "start" : {
257
+ "line" : 3 ,
258
+ "column" : 1
259
+ },
260
+ "end" : {
261
+ "line" : 3 ,
262
+ "column" : 2
263
+ }
264
+ },
265
+ "name" : " a"
266
+ },
267
+ "typeAnnotation" : {
268
+ "type" : " TSNumberKeyword" ,
269
+ "start" : 56 ,
270
+ "end" : 62 ,
271
+ "loc" : {
272
+ "start" : {
273
+ "line" : 3 ,
274
+ "column" : 6
275
+ },
276
+ "end" : {
277
+ "line" : 3 ,
278
+ "column" : 12
279
+ }
280
+ }
281
+ }
282
+ },
283
+ "right" : {
284
+ "type" : " Literal" ,
285
+ "start" : 67 ,
286
+ "end" : 68 ,
287
+ "loc" : {
288
+ "start" : {
289
+ "line" : 3 ,
290
+ "column" : 17
291
+ },
292
+ "end" : {
293
+ "line" : 3 ,
294
+ "column" : 18
295
+ }
296
+ },
297
+ "value" : 3 ,
298
+ "raw" : " 3"
299
+ }
300
+ }
301
+ }
302
+ ],
303
+ "sourceType" : " module"
304
+ }
Original file line number Diff line number Diff line change
1
+ let a : number | undefined = 1 ;
2
+ ( a as number ) = 2 ;
3
+ ( a as number ) += 3 ;
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments