TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
export as namespace syntax in TypeScript is a module-level declaration that exposes a module’s exports to the global scope under a single specified identifier. It provides ambient type information for Universal Module Definition (UMD) libraries, allowing the TypeScript compiler to recognize the module’s members as global variables when a module loader is not present.
Syntax
- Type-Level Binding: The declaration does not emit runtime JavaScript to attach the module to the global object (e.g.,
windoworglobal). It strictly informs the TypeScript type checker that the underlying UMD bundle will handle the global assignment at runtime. - Module Requirement: It can only be declared inside a file that is already recognized as a module by the compiler (i.e., a file containing at least one top-level
importorexportstatement). - Single Declaration Limit: TypeScript strictly allows only one
export as namespacedeclaration per file. Attempting to declare multiple namespace aliases within the same module will result in a compiler error. - Global Access Resolution: By default, the declared global namespace identifier is only accessible in script files. If the consuming file is a module (meaning it contains top-level
importorexportstatements), TypeScript intentionally hides the global alias and throws an error (TS2686), enforcing explicit imports. However, this strict isolation can be bypassed by enabling theallowUmdGlobalAccesscompiler option (introduced in TypeScript 3.5), which explicitly permits module files to access UMD globals without requiring animportstatement.
tsconfig.json configuration:
1. Consumption in a Script File
Master TypeScript with Deep Grasping Methodology!Learn More





