On this page
  1. namespace
  2. Syntax & Overview
  3. Notes & Pitfalls
  4. Example

namespace

Prev: `enum` | Up: builtins | Next: utility_types
Rel: ES Modules, builtins, Structural Typing & Narrowing
Ref: TypeScript Docs — namespace
Tags: #public #web #typescript #builtins #tier/legacy


Syntax & Overview

namespace LegacyUtils { export function help() {} }

Legacy TypeScript internal module syntax predating ES Modules (import/export); emits runtime IIFE code.

Legacy / Avoid: Prefer ES Modules in all new code.

Notes & Pitfalls

Example

namespace Geometry {
  export interface Point { x: number; y: number }
  export function origin(): Point { return { x: 0, y: 0 }; }
}

const p: Geometry.Point = Geometry.origin();

Linked from

Related notes