On this page
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
- Legacy pre-ESM grouping syntax: Prefer standard ES modules (
import/export) in modern TypeScript;namespaceis mainly used in.d.tsdeclaration files.
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
- tuts/typescript/builtins/enum Linked here; links to this page; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins Linked here; links to this page; shared tags: #builtins, #typescript, #web
- tuts/typescript/type_system/structural_typing_and_narrowing Linked here; shared tags: #typescript, #web
- tuts/typescript/utility_types Linked here; shared tags: #typescript, #web
- tuts/javascript/tutorials/modules_and_error_handling Linked here; shared tags: #web
- tuts/typescript/builtins/any shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #builtins, #tier, #typescript, #web