TypeScript Compiler Options

removeComments — TypeScript compiler option

Removes ordinary comments from emitted output. This does not modify the source file or implement a general minifier. Be aware of license and documentation requirements; special generated directives such as source map links can still be emitted. 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.d.ts. 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": {    "removeComments": true  }}

Parameters & Attributes

NameTypeDescription
removeCommentsbooleanSet 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",    "removeComments": true,    "declaration": true  },  "files": [    "example.ts"  ]}// File: example.ts// inventory comment/** Public item. */export const count: number = 3;console.log(count);
TypeScript Reference