TypeScript Compiler Options
mapRoot — TypeScript compiler option
Changes the sourceMappingURL that emitted JavaScript advertises to source-map consumers. The compiler still writes the map to its normal local output path in the tested configuration; deploying the map to the advertised location is a separate task. The example URL is illustrative and not contacted. Default: unset. Create the named files in a clean local project. Run tsc -p tsconfig.json. Expected output files: dist/example.js, dist/example.js.map. Run node dist/example.js; expected stdout: '3'. Tested using TypeScript 5.8.3 and Node.js 22.16.0; local project instructions, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "mapRoot": "https://example.invalid/maps/" }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| mapRoot | source map location string | Set in compilerOptions; default: unset. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "sourceMap": true, "mapRoot": "https://example.invalid/maps/" }, "files": [ "example.ts" ]}// File: example.tsexport const count: number = 3;console.log(count);