TypeScript Syntax

declare global — global type augmentation

A module can augment global declarations through declare global. This changes the checker’s view of shared names, not the runtime environment. Avoid broad global patches; they can conflict with other packages. This fixture adds a unique global interface, then uses it locally. Observed output: 'ready'. 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
export {};declare global { interface Existing { member: T; } }

Working Example

Example Snippettypescript
export {};declare global { interface ByteMindAuditLabel { text: string; } }const label: ByteMindAuditLabel = { text: "ready" };console.log(label.text);
TypeScript Reference