TypeScript - Namespaces (Legacy)
Namespaces
Before ES modules, TS offered namespace
to group code. Prefer ES modules today. Namespaces can still be useful for global augmentation patterns.
namespace Geometry {
export interface Point { x: number; y: number }
export function dist(a: Point, b: Point) { return Math.hypot(a.x-b.x, a.y-b.y) }
}
const d = Geometry.dist({x:0,y:0},{x:3,y:4});