From 2601a3ad7922234ce98eaa3f6e80579a5a7d8213 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Thu, 26 Dec 2024 19:10:19 +0000 Subject: [PATCH] fix(semantic): reference flags not correctly resolved when after an export stmt --- .../src/rules/typescript/consistent_type_imports.rs | 8 ++++++++ crates/oxc_semantic/src/builder.rs | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/typescript/consistent_type_imports.rs b/crates/oxc_linter/src/rules/typescript/consistent_type_imports.rs index 607643b279a458..0c29635f85a5b3 100644 --- a/crates/oxc_linter/src/rules/typescript/consistent_type_imports.rs +++ b/crates/oxc_linter/src/rules/typescript/consistent_type_imports.rs @@ -1517,6 +1517,14 @@ fn test() { // ", // None, // ), + ( + "import { Bar } from './bar'; +export type { Baz } from './baz'; + +export class Foo extends Bar {} +", + None, + ), ]; let fail = vec![ diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 9503630f0f2ff4..3dcd0aec126d2b 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -491,7 +491,6 @@ impl<'a> SemanticBuilder<'a> { let symbol_flags = self.symbols.get_flags(symbol_id); references.retain(|&reference_id| { let reference = &mut self.symbols.references[reference_id]; - let flags = reference.flags_mut(); // Determine the symbol whether can be referenced by this reference. @@ -1880,6 +1879,9 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> { if let Some(with_clause) = &it.with_clause { self.visit_with_clause(with_clause); } + if it.source.is_some() { + mem::take(&mut self.current_reference_flags); + } self.leave_node(kind); }