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.
This commit is contained in:
Dunqing 2024-07-29 03:39:18 +00:00
parent 43f2df8416
commit cf1854be7c
4 changed files with 6 additions and 3 deletions

View file

@ -442,6 +442,9 @@ impl<'a> SemanticBuilder<'a> {
// If the symbol is a value symbol and reference flag is not type-only, remove the type flag.
if symbol_flag.is_value() && !flag.is_type_only() {
*self.symbols.references[*id].flag_mut() -= ReferenceFlag::Type;
} else {
// If the symbol is a type symbol and reference flag is not type-only, remove the value flag.
*self.symbols.references[*id].flag_mut() -= ReferenceFlag::Value;
}
// import type { T } from './mod'; type A = typeof T

View file

@ -24,7 +24,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals3-
"node": "TSInterfaceDeclaration",
"references": [
{
"flag": "ReferenceFlag(Read | Type)",
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "Foo",
"node_id": 11

View file

@ -24,7 +24,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/named2-t
"node": "TSTypeAliasDeclaration",
"references": [
{
"flag": "ReferenceFlag(Read | Type)",
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "A",
"node_id": 8

View file

@ -24,7 +24,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/named3-t
"node": "TSTypeAliasDeclaration",
"references": [
{
"flag": "ReferenceFlag(Read | Type)",
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "V",
"node_id": 8