tsc command is the TypeScript compiler that compiles TypeScript files to JavaScript.
Installation
Basic Usage
Command-Line Options
Project Configuration
Compile the project given the path to its configuration file, or to a folder with a tsconfig.json.Aliases:
-pInitializes a TypeScript project and creates a tsconfig.json file.
Print the final configuration instead of building.
Build Options
Build one or more projects and their dependencies, if out of date.Aliases:
-bWatch input files and trigger recompilation on changes.Aliases:
-wSave .tsbuildinfo files to allow for incremental compilation of projects.Aliases:
-iTarget & Module Options
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, ESNextSpecify what module code is generated.Aliases:
-mValid values: CommonJS, AMD, UMD, System, ES6/ES2015, ES2020, ES2022, ESNext, Node16, Node18, Node20, NodeNext, PreserveSpecify 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
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.
Specify an output folder for all emitted files.
Generate .d.ts files from TypeScript and JavaScript files in your project.Aliases:
-dCreate sourcemaps for d.ts files.
Create source map files for emitted JavaScript files.
Disable emitting comments.
Disable emitting files from a compilation.
Only output d.ts files and not JavaScript files.
Type Checking Options
Enable all strict type-checking options.
Enable error reporting for expressions and declarations with an implied ‘any’ type.
When type checking, take into account null and undefined.
When assigning functions, check to ensure parameters and the return values are subtype-compatible.
Diagnostic Options
Enable color and formatting in TypeScript’s output to make compiler errors easier to read.
Output compiler performance information after building.
Output more detailed compiler performance information after building.
Print all of the files read during the compilation.
Print files read during the compilation including why it was included.
Log paths used during the moduleResolution process.
Help & Version
Print this help message.Aliases:
-h, -?Print the compiler’s version.Aliases:
-vShow 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
Compilation succeeded with no errors.
Compilation failed with type errors.
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.