TypeScript Compiler Options
libReplacement — TypeScript compiler option
Permits resolving built-in library declarations via @typescript/lib-* packages in 5.8.3. Turning it off uses bundled libraries instead. The option was introduced in 5.8 and the default changed in 6.0. This does not supply runtime APIs. Default in 5.8.3: true. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected diagnostics: []. Expected emitted files: none. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "libReplacement": true }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| libReplacement | boolean | Set in compilerOptions; default in 5.8.3: true. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "lib": [ "ES5", "DOM" ], "libReplacement": true, "noEmit": true }, "files": [ "main.ts" ]}// File: main.tsconst marker: "custom" = customDomMarker;// File: node_modules/@typescript/lib-dom/package.json{"name":"@typescript/lib-dom","version":"1.0.0","types":"index.d.ts"}// File: node_modules/@typescript/lib-dom/index.d.tsdeclare const customDomMarker: "custom";