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

Fix wrong scope for generic attribute #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions 9 src/script/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
typeDefScope: Scope,
isRemoveTarget: (nodeOrToken: HasLocation) => boolean,
) {
for (const variable of typeDefScope.variables) {
// eslint-disable-next-line unicorn/no-useless-spread -- The original array is mutated
for (const variable of [...typeDefScope.variables]) {
let def = variable.defs.find((d) =>
isRemoveTarget(d.name as HasLocation),
)
Expand All @@ -105,13 +106,15 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
)
}
}
for (const reference of typeDefScope.references) {
// eslint-disable-next-line unicorn/no-useless-spread -- The original array is mutated
for (const reference of [...typeDefScope.references]) {
if (isRemoveTarget(reference.identifier as HasLocation)) {
removeReference(reference, typeDefScope)
}
}

for (const scope of scopeManager.scopes) {
// eslint-disable-next-line unicorn/no-useless-spread -- The original array is mutated
for (const scope of [...scopeManager.scopes]) {
if (isRemoveTarget(scope.block as HasLocation)) {
removeScope(scopeManager, scope)
}
Expand Down
4 changes: 2 additions & 2 deletions 4 test/fixtures/ast/define-model05-with-modifiers/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
],
"name": "set"
},
"kind": "init",
"value": {
"type": "FunctionExpression",
"start": 71,
Expand Down Expand Up @@ -522,7 +521,8 @@
}
]
}
}
},
"kind": "init"
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/multiple-scripts-5/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "ImportDeclaration",
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/multiple-scripts-6/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@
"kind": "const"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
}
],
"sourceType": "module",
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/multiple-scripts-7/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "ImportDeclaration",
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/multiple-scripts-8/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "VariableDeclaration",
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/multiple-scripts-with-export01/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
}
],
"sourceType": "module",
Expand Down
12 changes: 8 additions & 4 deletions 12 test/fixtures/ast/multiple-scripts-with-export02/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "ImportDeclaration",
Expand Down Expand Up @@ -914,7 +915,8 @@
}
}
],
"source": null
"source": null,
"attributes": []
},
{
"type": "ExportNamedDeclaration",
Expand Down Expand Up @@ -1055,7 +1057,8 @@
}
}
],
"source": null
"source": null,
"attributes": []
},
{
"type": "ExportNamedDeclaration",
Expand All @@ -1077,7 +1080,8 @@
],
"declaration": null,
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "VariableDeclaration",
Expand Down
12 changes: 8 additions & 4 deletions 12 test/fixtures/ast/multiple-scripts-with-export04/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "ExportNamedDeclaration",
Expand Down Expand Up @@ -221,7 +222,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "ImportDeclaration",
Expand Down Expand Up @@ -467,7 +469,8 @@
}
}
],
"source": null
"source": null,
"attributes": []
},
{
"type": "ExportNamedDeclaration",
Expand Down Expand Up @@ -570,7 +573,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
}
],
"sourceType": "module",
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/multiple-scripts/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@
"kind": "const"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "VariableDeclaration",
Expand Down
8 changes: 4 additions & 4 deletions 8 test/fixtures/ast/script-setup-example13/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@
],
"name": "a"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 62,
Expand All @@ -360,7 +359,8 @@
63
],
"name": "a"
}
},
"kind": "init"
},
{
"type": "Property",
Expand Down Expand Up @@ -403,7 +403,6 @@
],
"name": "b"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 67,
Expand All @@ -423,7 +422,8 @@
68
],
"name": "b"
}
},
"kind": "init"
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/script-setup-example14/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@
"kind": "const"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
},
{
"type": "VariableDeclaration",
Expand Down
3 changes: 2 additions & 1 deletion 3 test/fixtures/ast/script-setup-with-export/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
}
],
"sourceType": "module",
Expand Down
8 changes: 4 additions & 4 deletions 8 test/fixtures/ast/slot-scope-destructuring/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@
],
"name": "a"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 58,
Expand All @@ -339,7 +338,8 @@
59
],
"name": "a"
}
},
"kind": "init"
},
{
"type": "Property",
Expand Down Expand Up @@ -382,7 +382,6 @@
],
"name": "b"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 61,
Expand All @@ -402,7 +401,8 @@
62
],
"name": "b"
}
},
"kind": "init"
},
{
"type": "RestElement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
],
"name": "data"
},
"kind": "init",
"value": {
"type": "FunctionExpression",
"start": 33,
Expand Down Expand Up @@ -244,7 +243,8 @@
}
]
}
}
},
"kind": "init"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
],
"name": "data"
},
"kind": "init",
"value": {
"type": "FunctionExpression",
"start": 33,
Expand Down Expand Up @@ -286,7 +285,8 @@
}
]
}
}
},
"kind": "init"
}
]
}
Expand Down
12 changes: 6 additions & 6 deletions 12 test/fixtures/ast/v-for-directives-with-destructuring/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@
],
"name": "key"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 28,
Expand All @@ -282,7 +281,8 @@
31
],
"name": "key"
}
},
"kind": "init"
},
{
"type": "Property",
Expand Down Expand Up @@ -325,7 +325,6 @@
],
"name": "name"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 32,
Expand All @@ -345,7 +344,8 @@
36
],
"name": "name"
}
},
"kind": "init"
}
]
}
Expand Down Expand Up @@ -1460,7 +1460,6 @@
],
"name": "name"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 163,
Expand All @@ -1480,7 +1479,8 @@
167
],
"name": "name"
}
},
"kind": "init"
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions 4 test/fixtures/ast/v-slot-default-shorthand/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
],
"name": "foo"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 43,
Expand All @@ -300,7 +299,8 @@
46
],
"name": "foo"
}
},
"kind": "init"
}
]
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.