TypeScript Syntax
declare enum — ambient enum contract
An ambient enum describes an externally supplied enumeration and produces no enum object. Uninitialized members of an ambient non-const enum are treated as computed. The example assigns a known numeric member value without reading an external runtime object. Observed output: '1'. Local verification: TypeScript 5.8.3, strict mode, ES2022, CommonJS, Node.js 22.16.0. Disposable library declarations are enabled for the fixture suite.
Formal Syntax & Structure
typescript syntaxtypescript
declare enum Status { Ready = 1 }Working Example
Example Snippettypescript
declare enum ExternalState { Ready = 1 }const state: ExternalState = 1;console.log(state);