Skip to content

Commit

Permalink
fix(semantic): TSExportAssignment cannot reference type binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Jul 27, 2024
1 parent d6fd06c commit 0676a8d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,13 @@ impl<'a> SemanticBuilder<'a> {
}
}
}
AstKind::TSExportAssignment(export) => {
// export = a;
// ^ can reference value or type
if export.expression.is_identifier_reference() {
self.current_reference_flag = ReferenceFlag::Read | ReferenceFlag::Type;
}
}
AstKind::IdentifierReference(ident) => {
self.reference_identifier(ident);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals1.
"flag": "ReferenceFlag(Read)",
"id": 0,
"name": "x",
"node_id": 6
"node_id": 7
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals3-
"id": 0,
"name": "Foo",
"node": "TSInterfaceDeclaration",
"references": []
"references": [
{
"flag": "ReferenceFlag(Read | Type)",
"id": 0,
"name": "Foo",
"node_id": 11
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals4-
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "T",
"node_id": 10
"node_id": 11
}
]
}
Expand Down

0 comments on commit 0676a8d

Please sign in to comment.