Skip to content

Commit cf1854b

Browse files
committed
feat(semantic): remove ReferenceFlags::Value from non-type-only exports that referenced type binding (#4511)
```ts type T = 0; export { T } ^ ReferenceFlags::Type | ReferenceFlags::Read ``` The export `T` only referenced type binding. We should remove `ReferenceFlags::Read` for it.
1 parent 43f2df8 commit cf1854b

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

crates/oxc_semantic/src/builder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ impl<'a> SemanticBuilder<'a> {
442442
// If the symbol is a value symbol and reference flag is not type-only, remove the type flag.
443443
if symbol_flag.is_value() && !flag.is_type_only() {
444444
*self.symbols.references[*id].flag_mut() -= ReferenceFlag::Type;
445+
} else {
446+
// If the symbol is a type symbol and reference flag is not type-only, remove the value flag.
447+
*self.symbols.references[*id].flag_mut() -= ReferenceFlag::Value;
445448
}
446449

447450
// import type { T } from './mod'; type A = typeof T

crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals3-type.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals3-
2424
"node": "TSInterfaceDeclaration",
2525
"references": [
2626
{
27-
"flag": "ReferenceFlag(Read | Type)",
27+
"flag": "ReferenceFlag(Type)",
2828
"id": 0,
2929
"name": "Foo",
3030
"node_id": 11

crates/oxc_semantic/tests/fixtures/typescript-eslint/export/named2-type.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/named2-t
2424
"node": "TSTypeAliasDeclaration",
2525
"references": [
2626
{
27-
"flag": "ReferenceFlag(Read | Type)",
27+
"flag": "ReferenceFlag(Type)",
2828
"id": 0,
2929
"name": "A",
3030
"node_id": 8

crates/oxc_semantic/tests/fixtures/typescript-eslint/export/named3-type.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/named3-t
2424
"node": "TSTypeAliasDeclaration",
2525
"references": [
2626
{
27-
"flag": "ReferenceFlag(Read | Type)",
27+
"flag": "ReferenceFlag(Type)",
2828
"id": 0,
2929
"name": "V",
3030
"node_id": 8

0 commit comments

Comments
 (0)