Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(semantic): generic passed to typeof not counted as a reference
  • Loading branch information
Dunqing committed Jul 27, 2024
commit 2e5d03f717a4968f3ae4d34e6ddf801199eba1f2
5 changes: 5 additions & 0 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,11 @@ impl<'a> SemanticBuilder<'a> {
// ^^^^^^^^
self.current_reference_flag = ReferenceFlag::Read | ReferenceFlag::TSTypeQuery;
}
AstKind::TSTypeParameterInstantiation(_) => {
// type A<T> = typeof a<T>;
// ^^^ avoid treat T as a value and TSTypeQuery
self.current_reference_flag -= ReferenceFlag::Read | ReferenceFlag::TSTypeQuery;
}
AstKind::TSTypeName(_) => {
match self.nodes.parent_kind(self.current_node_id) {
Some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/instantiation-e
"id": 4,
"name": "T",
"node": "TSTypeParameter",
"references": []
"references": [
{
"flag": "ReferenceFlag(Type)",
"id": 3,
"name": "T",
"node_id": 31
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"id": 4,
"name": "T",
"node": "TSTypeParameter",
"references": []
"references": [
{
"flag": "ReferenceFlag(Type)",
"id": 3,
"name": "T",
"node_id": 33
}
]
}
]
}
Expand Down