Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8fef4ca

Browse filesBrowse files
authored
Fix wrong scope for generic attribute (#254)
* Fix wrong scope for generic attribute * update
1 parent 2af9766 commit 8fef4ca
Copy full SHA for 8fef4ca

File tree

22 files changed

+95
-173
lines changed
Filter options

22 files changed

+95
-173
lines changed

‎src/script/generic.ts

Copy file name to clipboardExpand all lines: src/script/generic.ts
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
9494
typeDefScope: Scope,
9595
isRemoveTarget: (nodeOrToken: HasLocation) => boolean,
9696
) {
97-
for (const variable of typeDefScope.variables) {
97+
// eslint-disable-next-line unicorn/no-useless-spread -- The original array is mutated
98+
for (const variable of [...typeDefScope.variables]) {
9899
let def = variable.defs.find((d) =>
99100
isRemoveTarget(d.name as HasLocation),
100101
)
@@ -105,13 +106,15 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
105106
)
106107
}
107108
}
108-
for (const reference of typeDefScope.references) {
109+
// eslint-disable-next-line unicorn/no-useless-spread -- The original array is mutated
110+
for (const reference of [...typeDefScope.references]) {
109111
if (isRemoveTarget(reference.identifier as HasLocation)) {
110112
removeReference(reference, typeDefScope)
111113
}
112114
}
113115

114-
for (const scope of scopeManager.scopes) {
116+
// eslint-disable-next-line unicorn/no-useless-spread -- The original array is mutated
117+
for (const scope of [...scopeManager.scopes]) {
115118
if (isRemoveTarget(scope.block as HasLocation)) {
116119
removeScope(scopeManager, scope)
117120
}

‎test/fixtures/ast/define-model05-with-modifiers/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/define-model05-with-modifiers/ast.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@
214214
],
215215
"name": "set"
216216
},
217-
"kind": "init",
218217
"value": {
219218
"type": "FunctionExpression",
220219
"start": 71,
@@ -522,7 +521,8 @@
522521
}
523522
]
524523
}
525-
}
524+
},
525+
"kind": "init"
526526
}
527527
]
528528
}

‎test/fixtures/ast/multiple-scripts-5/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-5/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"kind": "let"
119119
},
120120
"specifiers": [],
121-
"source": null
121+
"source": null,
122+
"attributes": []
122123
},
123124
{
124125
"type": "ImportDeclaration",

‎test/fixtures/ast/multiple-scripts-6/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-6/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@
260260
"kind": "const"
261261
},
262262
"specifiers": [],
263-
"source": null
263+
"source": null,
264+
"attributes": []
264265
}
265266
],
266267
"sourceType": "module",

‎test/fixtures/ast/multiple-scripts-7/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-7/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"kind": "let"
119119
},
120120
"specifiers": [],
121-
"source": null
121+
"source": null,
122+
"attributes": []
122123
},
123124
{
124125
"type": "ImportDeclaration",

‎test/fixtures/ast/multiple-scripts-8/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-8/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"kind": "let"
119119
},
120120
"specifiers": [],
121-
"source": null
121+
"source": null,
122+
"attributes": []
122123
},
123124
{
124125
"type": "VariableDeclaration",

‎test/fixtures/ast/multiple-scripts-with-export01/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-with-export01/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@
200200
"kind": "let"
201201
},
202202
"specifiers": [],
203-
"source": null
203+
"source": null,
204+
"attributes": []
204205
}
205206
],
206207
"sourceType": "module",

‎test/fixtures/ast/multiple-scripts-with-export02/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-with-export02/ast.json
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@
364364
"kind": "let"
365365
},
366366
"specifiers": [],
367-
"source": null
367+
"source": null,
368+
"attributes": []
368369
},
369370
{
370371
"type": "ImportDeclaration",
@@ -914,7 +915,8 @@
914915
}
915916
}
916917
],
917-
"source": null
918+
"source": null,
919+
"attributes": []
918920
},
919921
{
920922
"type": "ExportNamedDeclaration",
@@ -1055,7 +1057,8 @@
10551057
}
10561058
}
10571059
],
1058-
"source": null
1060+
"source": null,
1061+
"attributes": []
10591062
},
10601063
{
10611064
"type": "ExportNamedDeclaration",
@@ -1077,7 +1080,8 @@
10771080
],
10781081
"declaration": null,
10791082
"specifiers": [],
1080-
"source": null
1083+
"source": null,
1084+
"attributes": []
10811085
},
10821086
{
10831087
"type": "VariableDeclaration",

‎test/fixtures/ast/multiple-scripts-with-export04/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-with-export04/ast.json
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"kind": "let"
119119
},
120120
"specifiers": [],
121-
"source": null
121+
"source": null,
122+
"attributes": []
122123
},
123124
{
124125
"type": "ExportNamedDeclaration",
@@ -221,7 +222,8 @@
221222
"kind": "let"
222223
},
223224
"specifiers": [],
224-
"source": null
225+
"source": null,
226+
"attributes": []
225227
},
226228
{
227229
"type": "ImportDeclaration",
@@ -467,7 +469,8 @@
467469
}
468470
}
469471
],
470-
"source": null
472+
"source": null,
473+
"attributes": []
471474
},
472475
{
473476
"type": "ExportNamedDeclaration",
@@ -570,7 +573,8 @@
570573
"kind": "let"
571574
},
572575
"specifiers": [],
573-
"source": null
576+
"source": null,
577+
"attributes": []
574578
}
575579
],
576580
"sourceType": "module",

‎test/fixtures/ast/multiple-scripts/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@
178178
"kind": "const"
179179
},
180180
"specifiers": [],
181-
"source": null
181+
"source": null,
182+
"attributes": []
182183
},
183184
{
184185
"type": "VariableDeclaration",

‎test/fixtures/ast/script-setup-example13/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/script-setup-example13/ast.json
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@
340340
],
341341
"name": "a"
342342
},
343-
"kind": "init",
344343
"value": {
345344
"type": "Identifier",
346345
"start": 62,
@@ -360,7 +359,8 @@
360359
63
361360
],
362361
"name": "a"
363-
}
362+
},
363+
"kind": "init"
364364
},
365365
{
366366
"type": "Property",
@@ -403,7 +403,6 @@
403403
],
404404
"name": "b"
405405
},
406-
"kind": "init",
407406
"value": {
408407
"type": "Identifier",
409408
"start": 67,
@@ -423,7 +422,8 @@
423422
68
424423
],
425424
"name": "b"
426-
}
425+
},
426+
"kind": "init"
427427
}
428428
]
429429
}

‎test/fixtures/ast/script-setup-example14/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/script-setup-example14/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@
178178
"kind": "const"
179179
},
180180
"specifiers": [],
181-
"source": null
181+
"source": null,
182+
"attributes": []
182183
},
183184
{
184185
"type": "VariableDeclaration",

‎test/fixtures/ast/script-setup-with-export/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/script-setup-with-export/ast.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"kind": "let"
119119
},
120120
"specifiers": [],
121-
"source": null
121+
"source": null,
122+
"attributes": []
122123
}
123124
],
124125
"sourceType": "module",

‎test/fixtures/ast/slot-scope-destructuring/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/slot-scope-destructuring/ast.json
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@
319319
],
320320
"name": "a"
321321
},
322-
"kind": "init",
323322
"value": {
324323
"type": "Identifier",
325324
"start": 58,
@@ -339,7 +338,8 @@
339338
59
340339
],
341340
"name": "a"
342-
}
341+
},
342+
"kind": "init"
343343
},
344344
{
345345
"type": "Property",
@@ -382,7 +382,6 @@
382382
],
383383
"name": "b"
384384
},
385-
"kind": "init",
386385
"value": {
387386
"type": "Identifier",
388387
"start": 61,
@@ -402,7 +401,8 @@
402401
62
403402
],
404403
"name": "b"
405-
}
404+
},
405+
"kind": "init"
406406
},
407407
{
408408
"type": "RestElement",

‎test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
],
9696
"name": "data"
9797
},
98-
"kind": "init",
9998
"value": {
10099
"type": "FunctionExpression",
101100
"start": 33,
@@ -244,7 +243,8 @@
244243
}
245244
]
246245
}
247-
}
246+
},
247+
"kind": "init"
248248
}
249249
]
250250
}

‎test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
],
9696
"name": "data"
9797
},
98-
"kind": "init",
9998
"value": {
10099
"type": "FunctionExpression",
101100
"start": 33,
@@ -286,7 +285,8 @@
286285
}
287286
]
288287
}
289-
}
288+
},
289+
"kind": "init"
290290
}
291291
]
292292
}

‎test/fixtures/ast/v-for-directives-with-destructuring/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/v-for-directives-with-destructuring/ast.json
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@
262262
],
263263
"name": "key"
264264
},
265-
"kind": "init",
266265
"value": {
267266
"type": "Identifier",
268267
"start": 28,
@@ -282,7 +281,8 @@
282281
31
283282
],
284283
"name": "key"
285-
}
284+
},
285+
"kind": "init"
286286
},
287287
{
288288
"type": "Property",
@@ -325,7 +325,6 @@
325325
],
326326
"name": "name"
327327
},
328-
"kind": "init",
329328
"value": {
330329
"type": "Identifier",
331330
"start": 32,
@@ -345,7 +344,8 @@
345344
36
346345
],
347346
"name": "name"
348-
}
347+
},
348+
"kind": "init"
349349
}
350350
]
351351
}
@@ -1460,7 +1460,6 @@
14601460
],
14611461
"name": "name"
14621462
},
1463-
"kind": "init",
14641463
"value": {
14651464
"type": "Identifier",
14661465
"start": 163,
@@ -1480,7 +1479,8 @@
14801479
167
14811480
],
14821481
"name": "name"
1483-
}
1482+
},
1483+
"kind": "init"
14841484
}
14851485
]
14861486
}

‎test/fixtures/ast/v-slot-default-shorthand/ast.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/v-slot-default-shorthand/ast.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@
280280
],
281281
"name": "foo"
282282
},
283-
"kind": "init",
284283
"value": {
285284
"type": "Identifier",
286285
"start": 43,
@@ -300,7 +299,8 @@
300299
46
301300
],
302301
"name": "foo"
303-
}
302+
},
303+
"kind": "init"
304304
}
305305
]
306306
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.