> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Namespace Import

A namespace import is an ECMAScript module syntax feature supported by TypeScript that binds all exported members of a target module into a single, locally scoped identifier. At runtime, this identifier acts as a module namespace exotic object encapsulating all named and default exports as read-only properties. During compilation, TypeScript extends this behavior by allowing the same identifier to act as a namespace for accessing exported types, which are subsequently erased during the emit phase.

```typescript theme={"dark"}
import * as AliasName from "module-path";
```

## 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.

```typescript theme={"dark"}
// --- target-module.ts 
export const TIMEOUT_MS = 5000;
export function initialize() {}
export interface SystemConfig { strict: boolean; }
export default class Core {}

// --- consumer.ts 
import * as System from "./target-module";

// 1. Value Access (Named Exports)
const time = System.TIMEOUT_MS;
System.initialize();

// 2. Value Access (Default Export)
const coreInstance = new System.default();

// 3. Type Access (TypeScript Specific)
// The alias 'System' is used in a type position to access 'SystemConfig'
const config: System.SystemConfig = { strict: true };
```

## Type-Only Namespace Imports

TypeScript 3.8 introduced the ability to prefix a namespace import with the `type` modifier. This guarantees that the namespace object is completely erased during the emit phase and only exists in the TypeScript AST for type checking.

```typescript theme={"dark"}
import type * as SystemTypes from "./target-module";

// Valid: Accessing types
const config: SystemTypes.SystemConfig = { strict: true };

// TS1361: 'SystemTypes' cannot be used as a value because it was imported using 'import type'.
const time = SystemTypes.TIMEOUT_MS; 
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor TypeScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
