TypeScript Compiler Options
sourceMap — TypeScript compiler option
Produces an external JavaScript source map mapping generated code to original source locations, with a sourceMappingURL in the emitted JavaScript. Debuggers need the corresponding source or embedded source text; this does not change application logic. Mutually exclusive with inlineSourceMap. Default: False when omitted. Create the named files in a clean local project and run tsc -p tsconfig.json. Expected emitted files: dist/example.js, dist/example.js.map. Run node dist/example.js; expected stdout: '3'. Tested with TypeScript 5.8.3 and Node.js 22.16.0; local project example, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "sourceMap": true }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| sourceMap | boolean | Set in compilerOptions; False when omitted. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "sourceMap": true }, "files": [ "example.ts" ]}// File: example.tsexport const count: number = 3;console.log(count);