TypeScript Syntax

declare — ambient declaration

An ambient declaration describes a binding expected to exist elsewhere. It supplies static information without implementing the declared binding. Referencing a declared value at runtime requires a real provider. This example uses the declaration only to derive a function type. Observed output: '#7'. 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 function name(arg: T): U;

Working Example

Example Snippettypescript
declare function format(value: number): string;const local: typeof format = n => `#${n}`;console.log(local(7));
TypeScript Reference