mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(semantic): incorrect reference when MemberExpression used in TSPropertySignature (#5525)
close: https://github.com/oxc-project/oxc/issues/5435#issuecomment-2333032168
This commit is contained in:
parent
b4f75967bd
commit
7a797ac635
5 changed files with 34 additions and 9 deletions
|
|
@ -1891,9 +1891,9 @@ impl<'a> SemanticBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AstKind::MemberExpression(_) => {
|
AstKind::MemberExpression(_) => {
|
||||||
if !self.current_reference_flags.is_type() {
|
// A.B = 1;
|
||||||
self.current_reference_flags = ReferenceFlags::Read;
|
// ^^^ we can't treat A as Write reference, because it's the property(B) of A that change
|
||||||
}
|
self.current_reference_flags -= ReferenceFlags::Write;
|
||||||
}
|
}
|
||||||
AstKind::AssignmentTarget(_) => {
|
AstKind::AssignmentTarget(_) => {
|
||||||
self.current_reference_flags |= ReferenceFlags::Write;
|
self.current_reference_flags |= ReferenceFlags::Write;
|
||||||
|
|
@ -1966,8 +1966,7 @@ impl<'a> SemanticBuilder<'a> {
|
||||||
self.current_reference_flags -= ReferenceFlags::Read;
|
self.current_reference_flags -= ReferenceFlags::Read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AstKind::MemberExpression(_)
|
AstKind::ExportNamedDeclaration(_)
|
||||||
| AstKind::ExportNamedDeclaration(_)
|
|
||||||
| AstKind::TSTypeQuery(_)
|
| AstKind::TSTypeQuery(_)
|
||||||
// Clear the reference flags that are set in AstKind::PropertySignature
|
// Clear the reference flags that are set in AstKind::PropertySignature
|
||||||
| AstKind::PropertyKey(_) => {
|
| AstKind::PropertyKey(_) => {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,13 @@ input_file: crates/oxc_semantic/tests/fixtures/oxc/type-declarations/signatures/
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"node": "TSInterfaceDeclaration",
|
"node": "TSInterfaceDeclaration",
|
||||||
"symbols": []
|
"symbols": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"children": [],
|
||||||
|
"flags": "ScopeFlags(StrictMode)",
|
||||||
|
"id": 3,
|
||||||
|
"node": "TSInterfaceDeclaration",
|
||||||
|
"symbols": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"flags": "ScopeFlags(StrictMode | Top)",
|
"flags": "ScopeFlags(StrictMode | Top)",
|
||||||
|
|
@ -35,6 +42,12 @@ input_file: crates/oxc_semantic/tests/fixtures/oxc/type-declarations/signatures/
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"name": "X",
|
"name": "X",
|
||||||
"node_id": 15
|
"node_id": 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"flags": "ReferenceFlags(Type)",
|
||||||
|
"id": 2,
|
||||||
|
"name": "X",
|
||||||
|
"node_id": 27
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -49,6 +62,12 @@ input_file: crates/oxc_semantic/tests/fixtures/oxc/type-declarations/signatures/
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "B",
|
"name": "B",
|
||||||
"node_id": 19
|
"node_id": 19
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"flags": "ReferenceFlags(Type)",
|
||||||
|
"id": 3,
|
||||||
|
"name": "B",
|
||||||
|
"node_id": 32
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
import type X from 'mod';
|
import type X from "mod";
|
||||||
|
|
||||||
type B = number;
|
type B = number;
|
||||||
|
|
||||||
export interface A {
|
export interface A {
|
||||||
[X]: B
|
[X]: B;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface A {
|
||||||
|
[X.X]: B;
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +39,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
|
||||||
"node": "TSEnumDeclaration(Foo)",
|
"node": "TSEnumDeclaration(Foo)",
|
||||||
"references": [
|
"references": [
|
||||||
{
|
{
|
||||||
"flags": "ReferenceFlags(Read)",
|
"flags": "ReferenceFlags(Type)",
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"name": "Foo",
|
"name": "Foo",
|
||||||
"node_id": 11
|
"node_id": 11
|
||||||
|
|
|
||||||
|
|
@ -16756,6 +16756,9 @@ rebuilt : SymbolId(20): [ReferenceId(14), ReferenceId(15), ReferenceId(17
|
||||||
Symbol reference IDs mismatch:
|
Symbol reference IDs mismatch:
|
||||||
after transform: SymbolId(25): [ReferenceId(13)]
|
after transform: SymbolId(25): [ReferenceId(13)]
|
||||||
rebuilt : SymbolId(21): []
|
rebuilt : SymbolId(21): []
|
||||||
|
Reference flags mismatch:
|
||||||
|
after transform: ReferenceId(12): ReferenceFlags(Write)
|
||||||
|
rebuilt : ReferenceId(16): ReferenceFlags(Read | Write)
|
||||||
|
|
||||||
tasks/coverage/typescript/tests/cases/compiler/missingSemicolonInModuleSpecifier.ts
|
tasks/coverage/typescript/tests/cases/compiler/missingSemicolonInModuleSpecifier.ts
|
||||||
semantic error: Bindings mismatch:
|
semantic error: Bindings mismatch:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue