diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs index 6c1aab88ba4b3..2b4dfe83d7323 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs @@ -337,15 +337,11 @@ impl NoUnusedVars { } fn should_skip_symbol(symbol: &Symbol<'_, '_>) -> bool { - const AMBIENT_NAMESPACE_FLAGS: SymbolFlags = - SymbolFlags::NameSpaceModule.union(SymbolFlags::Ambient); let flags = symbol.flags(); // 1. ignore enum members. Only enums get checked // 2. ignore all ambient TS declarations, e.g. `declare class Foo {}` - if flags.intersects(SymbolFlags::EnumMember.union(SymbolFlags::Ambient)) - // ambient namespaces - || flags == AMBIENT_NAMESPACE_FLAGS + if flags.intersects(SymbolFlags::EnumMember) || (symbol.is_in_ts() && symbol.is_in_declare_global()) { return true; diff --git a/crates/oxc_semantic/src/binder.rs b/crates/oxc_semantic/src/binder.rs index 9747af557a0de..32f8c448d1b1d 100644 --- a/crates/oxc_semantic/src/binder.rs +++ b/crates/oxc_semantic/src/binder.rs @@ -400,11 +400,10 @@ impl<'a> Binder<'a> for TSModuleDeclaration<'a> { // At declaration time a module has no value declaration it is only when a value declaration // is made inside a the scope of a module that the symbol is modified - let ambient = if self.declare { SymbolFlags::Ambient } else { SymbolFlags::None }; let symbol_id = builder.declare_symbol( self.id.span(), self.id.name().as_str(), - SymbolFlags::NameSpaceModule | ambient, + SymbolFlags::NameSpaceModule, SymbolFlags::None, ); diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 7a98ecb01f443..64008c4951025 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -2110,10 +2110,6 @@ impl<'a> SemanticBuilder<'a> { continue; }; - // Ambient modules cannot be value modules - if self.symbols.get_flags(symbol_id).intersects(SymbolFlags::Ambient) { - continue; - } self.symbols.union_flag(symbol_id, SymbolFlags::ValueModule); } } diff --git a/crates/oxc_semantic/tests/fixtures/typescript-eslint/ts-module/import.snap b/crates/oxc_semantic/tests/fixtures/typescript-eslint/ts-module/import.snap index 575aff84303f9..a814cc66a26c1 100644 --- a/crates/oxc_semantic/tests/fixtures/typescript-eslint/ts-module/import.snap +++ b/crates/oxc_semantic/tests/fixtures/typescript-eslint/ts-module/import.snap @@ -1,7 +1,7 @@ --- source: crates/oxc_semantic/tests/main.rs +assertion_line: 147 input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/ts-module/import.ts -snapshot_kind: text --- [ { @@ -27,7 +27,7 @@ snapshot_kind: text "node": "Program", "symbols": [ { - "flags": "SymbolFlags(NameSpaceModule | Ambient)", + "flags": "SymbolFlags(NameSpaceModule)", "id": 0, "name": "foo", "node": "TSModuleDeclaration(foo)", diff --git a/crates/oxc_syntax/src/symbol.rs b/crates/oxc_syntax/src/symbol.rs index 0003f4d3d6a56..20772941d25a8 100644 --- a/crates/oxc_syntax/src/symbol.rs +++ b/crates/oxc_syntax/src/symbol.rs @@ -115,10 +115,8 @@ bitflags! { const ConstEnum = 1 << 11; const EnumMember = 1 << 12; const TypeParameter = 1 << 13; - const NameSpaceModule = 1 << 14; - const ValueModule = 1 << 15; - // In a dts file or there is a declare flag - const Ambient = 1 << 16; + const NameSpaceModule = 1 << 14; // Uninstantiated module + const ValueModule = 1 << 15; // Instantiated module const Enum = Self::ConstEnum.bits() | Self::RegularEnum.bits(); const Variable = Self::FunctionScopedVariable.bits() | Self::BlockScopedVariable.bits();