Mechanics and Behavior
Module Resolution and Binding The* wildcard instructs the compiler to resolve the entire export graph of the target module. The compiler constructs a single identifier (AliasName) where each exported runtime member becomes a property on the module namespace exotic object.
Default Export Handling
If the target module contains a default export, the namespace import does not bind it to the root alias. Instead, it is explicitly attached to a property named default.
Immutability
The generated runtime namespace object is strictly read-only. TypeScript enforces this at compile time. Attempting to reassign a property on the namespace object throws TS2540: Cannot assign to 'Property' because it is a read-only property. Furthermore, attempting to reassign the namespace alias itself throws TS2628: Cannot assign to 'AliasName' because it is an import.
TypeScript Type Integration
While the runtime module namespace exotic object strictly contains values (functions, objects, primitives), TypeScript allows the namespace alias to be used in type positions to access compile-time constructs (interfaces, type aliases). The compiler resolves these type accesses during static analysis and completely erases them from the emitted JavaScript.Type-Only Namespace Imports
TypeScript 3.8 introduced the ability to prefix a namespace import with thetype modifier. This guarantees that the namespace object is completely erased during the emit phase and only exists in the TypeScript AST for type checking.
Tired of Poor TypeScript Skills? Fix That With Deep Grasping!Learn More





