-
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(semantic): reset references flags when resolved (#7923)
For this case, we set `current_reference_flags` to `ReferenceFlags::Type` for `TSInterfaceHeritage`, but never unset it, which causes resolving `fowardRef` identifier reuse `current_reference_flags` of `TSInterfaceHeritage`. ```ts import { forwardRef } from "react"; export interface MenuTriggerProps extends Object {} export const MenuTrigger = forwardRef(); ``` In this PR, reset the `current_reference_flags` when resolved, so that we don't need to reset it in individual visit functions. This is a reasonable change because the `current_reference_flags` only applies to the next encountered identifier.
- Loading branch information
Showing
4 changed files
with
60 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
crates/oxc_semantic/tests/fixtures/oxc/ts/exports/named/interface-heritage.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/oxc/ts/exports/named/interface-heritage.ts | ||
--- | ||
[ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"flags": "ScopeFlags(StrictMode)", | ||
"id": 1, | ||
"node": "TSInterfaceDeclaration", | ||
"symbols": [] | ||
} | ||
], | ||
"flags": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [ | ||
{ | ||
"flags": "SymbolFlags(Import)", | ||
"id": 0, | ||
"name": "forwardRef", | ||
"node": "ImportSpecifier(forwardRef)", | ||
"references": [ | ||
{ | ||
"flags": "ReferenceFlags(Read)", | ||
"id": 1, | ||
"name": "forwardRef", | ||
"node_id": 19 | ||
} | ||
] | ||
}, | ||
{ | ||
"flags": "SymbolFlags(Interface)", | ||
"id": 1, | ||
"name": "MenuTriggerProps", | ||
"node": "TSInterfaceDeclaration", | ||
"references": [] | ||
}, | ||
{ | ||
"flags": "SymbolFlags(BlockScopedVariable | ConstVariable)", | ||
"id": 2, | ||
"name": "MenuTrigger", | ||
"node": "VariableDeclarator(MenuTrigger)", | ||
"references": [] | ||
} | ||
] | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
crates/oxc_semantic/tests/fixtures/oxc/ts/exports/named/interface-heritage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { forwardRef } from "react"; | ||
export interface MenuTriggerProps extends Object {} | ||
export const MenuTrigger = forwardRef(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters