File tree 2 files changed +35
-129
lines changed
test/fixtures/ast/vue3.3-generic-3
2 files changed +35
-129
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,8 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
94
94
typeDefScope : Scope ,
95
95
isRemoveTarget : ( nodeOrToken : HasLocation ) => boolean ,
96
96
) {
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 ] ) {
98
99
let def = variable . defs . find ( ( d ) =>
99
100
isRemoveTarget ( d . name as HasLocation ) ,
100
101
)
@@ -105,13 +106,15 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
105
106
)
106
107
}
107
108
}
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 ] ) {
109
111
if ( isRemoveTarget ( reference . identifier as HasLocation ) ) {
110
112
removeReference ( reference , typeDefScope )
111
113
}
112
114
}
113
115
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 ] ) {
115
118
if ( isRemoveTarget ( scope . block as HasLocation ) ) {
116
119
removeScope ( scopeManager , scope )
117
120
}
Original file line number Diff line number Diff line change 1160
1160
"references" : []
1161
1161
},
1162
1162
{
1163
- "name" : " T " ,
1163
+ "name" : " defineProps " ,
1164
1164
"identifiers" : [],
1165
1165
"defs" : [],
1166
1166
"references" : [
1167
1167
{
1168
1168
"identifier" : {
1169
1169
"type" : " Identifier" ,
1170
- "name" : " T " ,
1170
+ "name" : " defineProps " ,
1171
1171
"loc" : {
1172
1172
"end" : {
1173
- "column " : 11 ,
1174
- "line " : 8
1173
+ "line " : 5 ,
1174
+ "column " : 21
1175
1175
},
1176
1176
"start" : {
1177
- "column " : 10 ,
1178
- "line " : 8
1177
+ "line " : 5 ,
1178
+ "column " : 10
1179
1179
}
1180
1180
}
1181
1181
},
1182
1182
"from" : " module" ,
1183
1183
"init" : null
1184
- },
1184
+ }
1185
+ ]
1186
+ },
1187
+ {
1188
+ "name" : " T" ,
1189
+ "identifiers" : [],
1190
+ "defs" : [],
1191
+ "references" : [
1185
1192
{
1186
1193
"identifier" : {
1187
1194
"type" : " Identifier" ,
1203
1210
]
1204
1211
},
1205
1212
{
1206
- "name" : " defineProps " ,
1213
+ "name" : " U " ,
1207
1214
"identifiers" : [],
1208
1215
"defs" : [],
1209
1216
"references" : [
1210
1217
{
1211
1218
"identifier" : {
1212
1219
"type" : " Identifier" ,
1213
- "name" : " defineProps " ,
1220
+ "name" : " U " ,
1214
1221
"loc" : {
1215
1222
"end" : {
1216
1223
"line" : 5 ,
1217
- "column" : 21
1224
+ "column" : 36
1218
1225
},
1219
1226
"start" : {
1220
1227
"line" : 5 ,
1221
- "column" : 10
1228
+ "column" : 35
1222
1229
}
1223
1230
}
1224
1231
},
1306
1313
}
1307
1314
]
1308
1315
},
1309
- {
1310
- "name" : " U" ,
1311
- "identifiers" : [
1312
- {
1313
- "type" : " Identifier" ,
1314
- "name" : " U" ,
1315
- "loc" : {
1316
- "end" : {
1317
- "column" : 6 ,
1318
- "line" : 8
1319
- },
1320
- "start" : {
1321
- "column" : 5 ,
1322
- "line" : 8
1323
- }
1324
- }
1325
- }
1326
- ],
1327
- "defs" : [
1328
- {
1329
- "type" : " Type" ,
1330
- "node" : {
1331
- "type" : " TSTypeAliasDeclaration" ,
1332
- "loc" : {
1333
- "end" : {
1334
- "column" : 1 ,
1335
- "line" : 9
1336
- },
1337
- "start" : {
1338
- "column" : 0 ,
1339
- "line" : 8
1340
- }
1341
- }
1342
- },
1343
- "name" : " U"
1344
- }
1345
- ],
1346
- "references" : [
1347
- {
1348
- "identifier" : {
1349
- "type" : " Identifier" ,
1350
- "name" : " U" ,
1351
- "loc" : {
1352
- "end" : {
1353
- "line" : 5 ,
1354
- "column" : 36
1355
- },
1356
- "start" : {
1357
- "line" : 5 ,
1358
- "column" : 35
1359
- }
1360
- }
1361
- },
1362
- "from" : " module" ,
1363
- "resolved" : {
1364
- "type" : " Identifier" ,
1365
- "name" : " U" ,
1366
- "loc" : {
1367
- "end" : {
1368
- "column" : 6 ,
1369
- "line" : 8
1370
- },
1371
- "start" : {
1372
- "column" : 5 ,
1373
- "line" : 8
1374
- }
1375
- }
1376
- },
1377
- "init" : null
1378
- }
1379
- ]
1380
- },
1381
1316
{
1382
1317
"name" : " p" ,
1383
1318
"identifiers" : [
1621
1556
}
1622
1557
],
1623
1558
"references" : [
1624
- {
1625
- "identifier" : {
1626
- "type" : " Identifier" ,
1627
- "name" : " T" ,
1628
- "loc" : {
1629
- "end" : {
1630
- "column" : 11 ,
1631
- "line" : 8
1632
- },
1633
- "start" : {
1634
- "column" : 10 ,
1635
- "line" : 8
1636
- }
1637
- }
1638
- },
1639
- "from" : " module" ,
1640
- "init" : null
1641
- },
1642
1559
{
1643
1560
"identifier" : {
1644
1561
"type" : " Identifier" ,
1723
1640
}
1724
1641
},
1725
1642
"from" : " module" ,
1726
- "resolved" : {
1727
- "type" : " Identifier" ,
1728
- "name" : " U" ,
1729
- "loc" : {
1730
- "end" : {
1731
- "column" : 6 ,
1732
- "line" : 8
1733
- },
1734
- "start" : {
1735
- "column" : 5 ,
1736
- "line" : 8
1737
- }
1738
- }
1739
- },
1740
1643
"init" : null
1741
1644
},
1742
1645
{
1860
1763
{
1861
1764
"identifier" : {
1862
1765
"type" : " Identifier" ,
1863
- "name" : " T " ,
1766
+ "name" : " defineProps " ,
1864
1767
"loc" : {
1865
1768
"end" : {
1866
- "column " : 11 ,
1867
- "line " : 8
1769
+ "line " : 5 ,
1770
+ "column " : 21
1868
1771
},
1869
1772
"start" : {
1870
- "column " : 10 ,
1871
- "line " : 8
1773
+ "line " : 5 ,
1774
+ "column " : 10
1872
1775
}
1873
1776
}
1874
1777
},
1878
1781
{
1879
1782
"identifier" : {
1880
1783
"type" : " Identifier" ,
1881
- "name" : " defineProps " ,
1784
+ "name" : " T " ,
1882
1785
"loc" : {
1883
1786
"end" : {
1884
1787
"line" : 5 ,
1885
- "column" : 21
1788
+ "column" : 28
1886
1789
},
1887
1790
"start" : {
1888
1791
"line" : 5 ,
1889
- "column" : 10
1792
+ "column" : 27
1890
1793
}
1891
1794
}
1892
1795
},
1896
1799
{
1897
1800
"identifier" : {
1898
1801
"type" : " Identifier" ,
1899
- "name" : " T " ,
1802
+ "name" : " U " ,
1900
1803
"loc" : {
1901
1804
"end" : {
1902
1805
"line" : 5 ,
1903
- "column" : 28
1806
+ "column" : 36
1904
1807
},
1905
1808
"start" : {
1906
1809
"line" : 5 ,
1907
- "column" : 27
1810
+ "column" : 35
1908
1811
}
1909
1812
}
1910
1813
},
You can’t perform that action at this time.
0 commit comments