declare

Declares the type of an entity that exists at runtime without emitting code.

Since TS 1.0 Spec ↗

Syntax

declare const/function/module/global ...

Examples

declare const VERSION: string;
declare function gtag(event: string, data: object): void;
declare module '*.css' {
  const classes: Record<string, string>;
  export default classes;
}

Notes

`declare` introduces ambient declarations used in `.d.ts` files or to describe globals and untyped modules. It produces no JavaScript output; the implementation is assumed to exist elsewhere. Pair with `declare global` to augment global scope.

See also