diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 6179d027ff3d2d..3c57834985c5f1 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -1712,6 +1712,9 @@ impl<'a> SemanticBuilder<'a> { AstKind::ExportSpecifier(s) if s.export_kind.is_type() => { self.current_reference_flag = ReferenceFlag::Type; } + AstKind::TSInterfaceHeritage(_) => { + self.current_reference_flag = ReferenceFlag::Type; + } AstKind::TSTypeName(_) => { match self.nodes.parent_kind(self.current_node_id) { Some( @@ -1740,7 +1743,9 @@ impl<'a> SemanticBuilder<'a> { self.reference_jsx_identifier(ident); } AstKind::UpdateExpression(_) => { - if self.is_not_expression_statement_parent() { + if !self.current_reference_flag.is_type() + && self.is_not_expression_statement_parent() + { self.current_reference_flag |= ReferenceFlag::Read; } self.current_reference_flag |= ReferenceFlag::Write; @@ -1753,7 +1758,9 @@ impl<'a> SemanticBuilder<'a> { } } AstKind::MemberExpression(_) => { - self.current_reference_flag = ReferenceFlag::Read; + if !self.current_reference_flag.is_type() { + self.current_reference_flag = ReferenceFlag::Read; + } } AstKind::AssignmentTarget(_) => { self.current_reference_flag |= ReferenceFlag::Write; diff --git a/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/interface-heritage1.snap b/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/interface-heritage1.snap index 680da985903960..a356b6eeb9b0cb 100644 --- a/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/interface-heritage1.snap +++ b/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/interface-heritage1.snap @@ -29,7 +29,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio "id": 0, "name": "Parent", "node": "TSInterfaceDeclaration", - "references": [] + "references": [ + { + "flag": "ReferenceFlag(Type)", + "id": 0, + "name": "Parent", + "node_id": 6 + } + ] }, { "flag": "SymbolFlags(Interface)", diff --git a/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.snap b/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.snap index 26be7934f19fbc..aee4855614865d 100644 --- a/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.snap +++ b/crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.snap @@ -52,7 +52,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio "id": 0, "name": "A", "node": "TSInterfaceDeclaration", - "references": [] + "references": [ + { + "flag": "ReferenceFlag(Type)", + "id": 0, + "name": "A", + "node_id": 9 + } + ] }, { "flag": "SymbolFlags(Interface)", diff --git a/crates/oxc_semantic/tests/integration/symbols.rs b/crates/oxc_semantic/tests/integration/symbols.rs index 6b4f861aaadc6c..1b21f10d5603a9 100644 --- a/crates/oxc_semantic/tests/integration/symbols.rs +++ b/crates/oxc_semantic/tests/integration/symbols.rs @@ -292,3 +292,16 @@ fn test_type_query() { .has_number_of_reads(0) .test(); } + +#[test] +fn test_ts_interface_heritage() { + SemanticTester::ts( + " + type Heritage = { x: number; y: string; }; + interface A extends (Heritage.x) {} + ", + ) + .has_some_symbol("Heritage") + .has_number_of_references(1) + .test(); +}