TypeScript Declaration Files
Triple-slash reference lib
A leading triple-slash lib directive requests a compiler-provided library declaration family. This adds Map declarations to an ES5 declaration environment, without installing a Map implementation. Runtime support or polyfills must be provided separately. Baseline: TypeScript 5.8.3. File labels are explanatory; create the files separately.
Formal Syntax & Structure
typescript syntaxtypescript
/// <reference lib="es2015.collection" />Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmit": true, "skipLibCheck": false, "lib": [ "ES5" ] }, "files": [ "main.ts" ]}
// File: main.ts (omit this label)/// <reference lib="es2015.collection" />const ids = new Map<number, string>();ids.set(1, "one");
// Run: tsc -p . --pretty false// Expected: no diagnostics.