tsc CLI Options
Running tsc locally will compile the closest project defined by a tsconfig.json , or you can compile a set of TypeScript files by passing in a glob of files you want. When input files are specified on the command line, tsconfig.json files are ignored.
sh
# Run a compile based on a backwards look through the fs for a tsconfig.jsontsc# Emit JS for just the index.ts with the compiler defaultstsc index.ts# Emit JS for any .ts files in the folder src, with the default settingstsc src/*.ts# Emit files referenced in with the compiler settings from tsconfig.production.jsontsc --project tsconfig.production.json# Emit d.ts files for a js file with showing compiler options which are booleanstsc index.js --declaration --emitDeclarationOnly# Emit a single .js file from two files via compiler options which take string argumentstsc app.ts util.ts --target esnext --outfile index.js
If you’re looking for more information about the compiler options in a tsconfig, check out the TSConfig Reference
CLI Commands
Show all compiler options.
Generates an event trace and a list of types.
Gives local information for help on the CLI.
Initializes a TypeScript project and creates a tsconfig.json file.
Print names of files that are part of the compilation and then stop processing.
Set the language of the messaging from TypeScript. This does not affect emit.
Compile the project given the path to its configuration file, or to a folder with a ‘tsconfig.json’.
Print the final configuration instead of building.
Print the compiler’s version.
Build Options
Build one or more projects and their dependencies, if out of date
Delete the outputs of all projects.
Show what would be built (or deleted, if specified with ‘—clean’)
Build all projects, including those that appear to be up to date.
Watch Options
Remove a list of directories from the watch process.
Remove a list of files from the watch mode’s processing.
fixedinterval , priorityinterval , dynamicpriority , or fixedchunksize
Specify what approach the watcher should use if the system runs out of native file watchers.
Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.
usefsevents , fixedpollinginterval , dynamicprioritypolling , or fixedchunksizepolling
Specify how directories are watched on systems that lack recursive file-watching functionality.
fixedpollinginterval , prioritypollinginterval , dynamicprioritypolling , fixedchunksizepolling , usefsevents , or usefseventsonparentdirectory
Specify how the TypeScript watch mode works.
Compiler Flags
Enable importing files with any extension, provided a declaration file is present.
Allow imports to include TypeScript file extensions.
Allow JavaScript files to be a part of your program. Use the checkJS option to get errors from these files.
true if esModuleInterop is enabled, module is system , or moduleResolution is bundler ; false otherwise.
Allow ‘import x from y’ when a module doesn’t have a default export.
Allow accessing UMD globals from modules.
Disable error reporting for unreachable code.
Disable error reporting for unused labels.
true if strict ; false otherwise.
Ensure ‘use strict’ is always emitted.
Have recompiles in projects that use incremental and watch mode assume that changes within a file will only affect files directly depending on it.
Specify the base directory to resolve non-relative module names.
No longer supported. In early versions, manually set the text encoding for reading files.
Enable error reporting in type-checked JavaScript files.
Enable constraints that allow a TypeScript project to be used with project references.
Conditions to set in addition to the resolver-specific defaults when resolving imports.
true if composite ; false otherwise.
Generate .d.ts files from TypeScript and JavaScript files in your project.
Specify the output directory for generated declaration files.
Create sourcemaps for d.ts files.
Output compiler performance information after building.
Reduce the number of projects loaded automatically by TypeScript.
Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.
Opt a project out of multi-project reference checking when editing.
Disable preferring source files instead of declaration files when referencing composite projects.
Emit more compliant, but verbose and less performant JavaScript for iteration.
Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
Only output d.ts files and not JavaScript files.
Emit design-type metadata for decorated declarations in source files.
true if module is node16 or nodenext ; false otherwise.
Emit additional JavaScript to ease support for importing CommonJS modules. This enables allowSyntheticDefaultImports for type compatibility.
Interpret optional property types as written, rather than adding undefined .
Enable experimental support for TC39 stage 2 draft decorators.
Print files read during the compilation including why it was included.
Output more detailed compiler performance information after building.
Ensure that casing is correct in imports.
Emit a v8 CPU profile of the compiler run for debugging.
Allow importing helper functions from tslib once per project, instead of including them per-file.
remove , preserve , or error
Specify emit/checking behavior for imports that are only used for types.
true if composite ; false otherwise.
Save .tsbuildinfo files to allow for incremental compilation of projects.
Include sourcemap files inside the emitted JavaScript.
Include source code in the sourcemaps inside the emitted JavaScript.
Ensure that each file can be safely transpiled without relying on other imports.
preserve , react , react-native , react-jsx , or react-jsxdev
Specify what JSX code is generated.
Specify the JSX factory function used when targeting React JSX emit, e.g. ‘React.createElement’ or ‘h’.
Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. ‘React.Fragment’ or ‘Fragment’.
Specify module specifier used to import the JSX factory functions when using jsx: react-jsx* .
Make keyof only return strings instead of string, numbers or symbols. Legacy option.
Specify a set of bundled library declaration files that describe the target runtime environment.
Print the names of emitted files after a compilation.
Print all of the files read during the compilation.
Specify the location where debugger should locate map files instead of generated locations.
Specify the maximum folder depth used for checking JavaScript files from node_modules . Only applicable with allowJs .
none , commonjs , amd , umd , system , es6 / es2015 , es2020 , es2022 , esnext , node16 , or nodenext
CommonJS if target is ES3 or ES5 ; ES6 / ES2015 otherwise.
Specify what module code is generated.
«auto»: Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules.
Specify what method is used to detect whether a file is a script or a module.
classic , node10 / node , node16 , nodenext , or bundler
Classic if module is AMD , UMD , System , or ES6 / ES2015 ; Matches if module is node16 or nodenext ; Node otherwise.
Specify how TypeScript looks up a file from a given module specifier.
List of file name suffixes to search when resolving a module.
Set the newline character for emitting files.
Disable emitting files from a compilation.
Disable generating custom helper functions like __extends in compiled output.
Disable emitting files if any type checking errors are reported.
Disable truncating types in error messages.
Enable error reporting for fallthrough cases in switch statements.
true if strict ; false otherwise.
Enable error reporting for expressions and declarations with an implied any type.
Ensure overriding members in derived classes are marked with an override modifier.
Enable error reporting for codepaths that do not explicitly return in a function.
true if strict ; false otherwise.
Enable error reporting when this is given the type any .
Disable adding ‘use strict’ directives in emitted JavaScript files.
Disable including any library files, including the default lib.d.ts.
Enforces using indexed accessors for keys declared using an indexed type.
Disallow import s, require s or s from expanding the number of files TypeScript should add to a project.
Disable strict checking of generic signatures in function types.
Add undefined to a type when accessed using an index.
Enable error reporting when local variables aren’t read.
Raise an error when a function parameter isn’t read.
Deprecated setting. Use outFile instead.
Specify an output folder for all emitted files.
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 a set of entries that re-map imports to additional lookup locations.
Specify a list of language service plugins to include.
true if isolatedModules ; false otherwise.
Disable erasing const enum declarations in generated code.
Disable resolving symlinks to their realpath. This correlates to the same flag in node.
Preserve unused imported values in the JavaScript output that would otherwise be removed.
Disable wiping the console in watch mode.
Enable color and formatting in TypeScript’s output to make compiler errors easier to read.
Specify the object invoked for createElement . This only applies when targeting react JSX emit.
Disable emitting comments.
Enable importing .json files.
true when moduleResolution is node16 , nodenext , or bundler ; otherwise false
Use the package.json ‘exports’ field when resolving package imports.
true when moduleResolution is node16 , nodenext , or bundler ; otherwise false
Use the package.json ‘imports’ field when resolving imports.
Computed from the list of input files.
Specify the root folder within your source files.
Computed from the list of input files.
Allow multiple folders to be treated as one when resolving modules.
Skip type checking .d.ts files that are included with TypeScript.
Skip type checking all .d.ts files.
Create source map files for emitted JavaScript files.
Specify the root path for debuggers to find the reference source code.
Enable all strict type-checking options.
true if strict ; false otherwise.
Check that the arguments for bind , call , and apply methods match the original function.
true if strict ; false otherwise.
When assigning functions, check to ensure parameters and the return values are subtype-compatible.
true if strict ; false otherwise.
When type checking, take into account null and undefined .
true if strict ; false otherwise.
Check for class properties that are declared but not set in the constructor.
Disable emitting declarations that have @internal in their JSDoc comments.
Disable reporting of excess property errors during the creation of object literals.
Suppress noImplicitAny errors when indexing objects that lack index signatures.
es3 , es5 , es6 / es2015 , es2016 , es2017 , es2018 , es2019 , es2020 , es2021 , es2022 , or esnext
Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
Log paths used during the moduleResolution process.
The file to store .tsbuildinfo incremental build information in.
Specify multiple folders that act like ./node_modules/@types .
Specify type package names to be included without being referenced in a source file.
true if target is ES2022 or higher, including ESNext ; false otherwise.
Emit ECMAScript-standard-compliant class fields.
true if strict ; false otherwise.
Default catch clause variables as unknown instead of any .
Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file’s format based on the ‘module’ setting.
- Every option is fully explained in the TSConfig Reference.
- Learn how to use a tsconfig.json files.
- Learn how to work in an MSBuild project.
The TypeScript docs are an open source project. Help us improve these pages by sending a Pull Request ❤