Skip to content

Commit

Permalink
fix(semantic): generic passed to typeof not counted as a reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Jul 27, 2024
1 parent 40cafb8 commit 2e5d03f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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

0 comments on commit 2e5d03f

Please sign in to comment.