tsc command is the TypeScript compiler that compiles TypeScript files to JavaScript.
Installation
Basic Usage
Command-Line Options
Project Configuration
string
default:"tsconfig.json"
Compile the project given the path to its configuration file, or to a folder with a tsconfig.json.Aliases:
-pboolean
default:"false"
Initializes a TypeScript project and creates a tsconfig.json file.
boolean
default:"false"
Print the final configuration instead of building.
Build Options
boolean
default:"false"
Build one or more projects and their dependencies, if out of date.Aliases:
-bboolean
default:"false"
Watch input files and trigger recompilation on changes.Aliases:
-wboolean
default:"false"
Save .tsbuildinfo files to allow for incremental compilation of projects.Aliases:
-iTarget & Module Options
string
default:"ES3"
Set the JavaScript language version for emitted JavaScript and include compatible library declarations.Aliases:
-tValid values: ES3, ES5, ES6/ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ES2023, ES2024, ES2025, ESNextstring
default:"computed"
Specify what module code is generated.Aliases:
-mValid values: CommonJS, AMD, UMD, System, ES6/ES2015, ES2020, ES2022, ESNext, Node16, Node18, Node20, NodeNext, Preservestring[]
Specify a set of bundled library declaration files that describe the target runtime environment.Valid values:
ES5, ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ES2023, ES2024, ES2025, ESNext, DOM, WebWorker, ScriptHostEmit Options
string
Specify a file that bundles all outputs into one JavaScript file. If declaration is true, also designates a file that bundles all .d.ts output.
string
Specify an output folder for all emitted files.
boolean
default:"false"
Generate .d.ts files from TypeScript and JavaScript files in your project.Aliases:
-dboolean
default:"false"
Create sourcemaps for d.ts files.
boolean
default:"false"
Create source map files for emitted JavaScript files.
boolean
default:"false"
Disable emitting comments.
boolean
default:"false"
Disable emitting files from a compilation.
boolean
default:"false"
Only output d.ts files and not JavaScript files.
Type Checking Options
boolean
default:"true"
Enable all strict type-checking options.
boolean
default:"true if strict"
Enable error reporting for expressions and declarations with an implied ‘any’ type.
boolean
default:"true if strict"
When type checking, take into account null and undefined.
boolean
default:"true if strict"
When assigning functions, check to ensure parameters and the return values are subtype-compatible.
Diagnostic Options
boolean
default:"true"
Enable color and formatting in TypeScript’s output to make compiler errors easier to read.
boolean
default:"false"
Output compiler performance information after building.
boolean
default:"false"
Output more detailed compiler performance information after building.
boolean
default:"false"
Print all of the files read during the compilation.
boolean
default:"false"
Print files read during the compilation including why it was included.
boolean
default:"false"
Log paths used during the moduleResolution process.
Help & Version
boolean
default:"false"
Print this help message.Aliases:
-h, -?boolean
default:"false"
Print the compiler’s version.Aliases:
-vboolean
default:"false"
Show all compiler options.
Real-World Examples
Basic Compilation
Compile a TypeScript file to JavaScript:Development Build
Compile with source maps and watch mode for development:Production Build
Compile for production with optimizations:Type Checking Only
Check types without emitting files:Project References
Build a project with references:Exit Codes
success
Compilation succeeded with no errors.
error
Compilation failed with type errors.
error
Invalid command-line arguments.
Performance Tips
Common Errors
Source Code Reference
The TypeScript compiler implementation:- Main entry point:
src/tsc/tsc.ts:24 - Command-line parser:
src/compiler/commandLineParser.ts - Build mode:
src/compiler/builder.ts
The
tsc binary (bin/tsc) is a wrapper that loads the compiled compiler from lib/tsc.js.