Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
source: crates/oxc_semantic/tests/main.rs
input_file: crates/oxc_semantic/tests/fixtures/oxc/ts/namespaces/value-module.ts
---
[
{
"children": [
{
"children": [
{
"children": [],
"flags": "ScopeFlags(StrictMode)",
"id": 2,
"node": "TSTypeAliasDeclaration",
"symbols": []
}
],
"flags": "ScopeFlags(StrictMode | TsModuleBlock)",
"id": 1,
"node": "TSModuleDeclaration(N1)",
"symbols": [
{
"flags": "SymbolFlags(BlockScopedVariable | ConstVariable)",
"id": 1,
"name": "A",
"node": "VariableDeclarator(A)",
"references": []
},
{
"flags": "SymbolFlags(TypeAlias)",
"id": 2,
"name": "B",
"node": "TSTypeAliasDeclaration",
"references": []
}
]
},
{
"children": [],
"flags": "ScopeFlags(StrictMode)",
"id": 3,
"node": "TSTypeAliasDeclaration",
"symbols": []
}
],
"flags": "ScopeFlags(StrictMode | Top)",
"id": 0,
"node": "Program",
"symbols": [
{
"flags": "SymbolFlags(ValueModule)",
"id": 0,
"name": "N1",
"node": "TSModuleDeclaration(N1)",
"references": [
{
"flags": "ReferenceFlags(Type)",
"id": 0,
"name": "N1",
"node_id": 22
},
{
"flags": "ReferenceFlags(Read)",
"id": 1,
"name": "N1",
"node_id": 28
}
]
},
{
"flags": "SymbolFlags(TypeAlias)",
"id": 3,
"name": "T1",
"node": "TSTypeAliasDeclaration",
"references": []
},
{
"flags": "SymbolFlags(BlockScopedVariable | ConstVariable)",
"id": 4,
"name": "T2",
"node": "VariableDeclarator(T2)",
"references": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace N1 {
export const A = 1;
export type B = 2;
}

type T1 = N1.B;
const T2 = N1.A;
6 changes: 4 additions & 2 deletions crates/oxc_syntax/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ bitflags! {
const BlockScoped = Self::BlockScopedVariable.bits() | Self::Enum.bits() | Self::Class.bits();

const Value = Self::Variable.bits() | Self::Class.bits() | Self::Function.bits() | Self::Enum.bits() | Self::EnumMember.bits() | Self::ValueModule.bits();
const Type = Self::Class.bits() | Self::Interface.bits() | Self::Enum.bits() | Self::EnumMember.bits() | Self::TypeParameter.bits() | Self::TypeAlias.bits();
const Type = Self::Class.bits() | Self::Interface.bits() | Self::Enum.bits() | Self::EnumMember.bits() | Self::TypeParameter.bits() | Self::TypeAlias.bits();
const Namespace = Self::ValueModule.bits() | Self::NamespaceModule.bits() | Self::Enum.bits();


/// Variables can be redeclared, but can not redeclare a block-scoped declaration with the
/// same name, or any other value that is not a variable, e.g. ValueModule or Class
Expand Down Expand Up @@ -270,7 +272,7 @@ impl SymbolFlags {
/// If true, then the symbol can be referenced by a type reference
#[inline]
pub fn can_be_referenced_by_type(&self) -> bool {
self.intersects(Self::Type | Self::TypeImport | Self::Import | Self::NamespaceModule)
self.intersects(Self::Type | Self::TypeImport | Self::Import | Self::Namespace)
}

/// If true, then the symbol can be referenced by a value reference
Expand Down
Loading
Loading