Was this page helpful?

tsc CLI Options

Using the CLI

Running tsc locally will compile the closest project defined by a tsconfig.json, you can compile a set of TypeScript files by passing in a glob of files you want.

# Run a compile based on a backwards look through the fs for a tsconfig.json
# Emit JS for just the index.ts with the compiler defaults
tsc index.ts
# Emit JS for any .ts files in the folder src, with the default settings
tsc src/*.ts
# Emit files referenced in with the compiler settings from tsconfig.production.json
tsc --project tsconfig.production.json
# Emit d.ts files for a js file with showing compiler options which are booleans
tsc index.js --declaration --emitDeclarationOnly
# Emit a single .js file from two files via compiler options which take string arguments
tsc app.ts util.ts --target esnext --outfile index.js

Compiler Options

If you’re looking for more information about the compiler options in a tsconfig, check out the TSConfig Reference

CLI Commands

Flag Type
--all boolean

Show all compiler options.

--generateTrace string

Generates an event trace and a list of types.

--help boolean

Gives local information for help on the CLI.

--init boolean

Initializes a TypeScript project and creates a tsconfig.json file.

--listFilesOnly boolean

Print names of files that are part of the compilation and then stop processing.

--locale string

Set the language of the messaging from TypeScript. This does not affect emit.

--project string

Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.

--showConfig boolean

Print the final configuration instead of building.

--version boolean

Print the compiler's version.

Build Options

Flag Type
--build boolean

Build one or more projects and their dependencies, if out of date

--clean boolean

Delete the outputs of all projects.

--dry boolean

Show what would be built (or deleted, if specified with '--clean')

--force boolean

Build all projects, including those that appear to be up to date

--verbose boolean

Enable verbose logging

Watch Options

Flag Type
--excludeDirectories list

Remove a list of directories from the watch process.

--excludeFiles list

Remove a list of files from the watch mode's processing.

--fallbackPolling fixedPollingInterval, priorityPollingInterval, or dynamicPriorityPolling

Specify what approach the watcher should use if the system runs out of native file watchers.

--synchronousWatchDirectory boolean

Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.

--watch boolean

Watch input files.

--watchDirectory fixedPollingInterval, dynamicPriorityPolling, or useFsEvents

Specify how directories are watched on systems that lack recursive file-watching functionality.

--watchFile fixedPollingInterval, priorityPollingInterval, dynamicPriorityPolling, useFsEvents, or useFsEventsOnParentDirectory

Specify how the TypeScript watch mode works.

Compiler Flags

Flag Type Default
--allowJs boolean


Allow JavaScript files to be a part of your program. Use the checkJS option to get errors from these files.

--allowSyntheticDefaultImports boolean

module === "system" or esModuleInterop

Allow 'import x from y' when a module doesn't have a default export.

--allowUmdGlobalAccess boolean


Allow accessing UMD globals from modules.

--allowUnreachableCode boolean


Disable error reporting for unreachable code.

--allowUnusedLabels boolean


Disable error reporting for unused labels.

--alwaysStrict boolean

false, unless strict is set

Ensure 'use strict' is always emitted.

--assumeChangesOnlyAffectDirectDependencies boolean

Have recompiles in projects that use incremental and watch mode assume that changes within a file will only affect files directly depending on it.

--baseUrl string

Specify the base directory to resolve non-relative module names.

--charset string


No longer supported. In early versions, manually set the text encoding for reading files.

--checkJs boolean


Enable error reporting in type-checked JavaScript files.

--composite boolean


Enable constraints that allow a TypeScript project to be used with project references.

--declaration boolean

false, unless composite is set

Generate .d.ts files from TypeScript and JavaScript files in your project.

--declarationDir string


Specify the output directory for generated declaration files.

--declarationMap boolean


Create sourcemaps for d.ts files.

--diagnostics boolean


Output compiler performance information after building.

--disableReferencedProjectLoad boolean

Reduce the number of projects loaded automatically by TypeScript.

--disableSizeLimit boolean


Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.

--disableSolutionSearching boolean

Opt a project out of multi-project reference checking when editing.

--disableSourceOfProjectReferenceRedirect boolean

Disable preferring source files instead of declaration files when referencing composite projects

--downlevelIteration boolean


Emit more compliant, but verbose and less performant JavaScript for iteration.

--emitBOM boolean


Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.

--emitDeclarationOnly boolean


Only output d.ts files and not JavaScript files.

--emitDecoratorMetadata boolean

Emit design-type metadata for decorated declarations in source files.

--esModuleInterop boolean


Emit additional JavaScript to ease support for importing CommonJS modules. This enables allowSyntheticDefaultImports for type compatibility.

--experimentalDecorators boolean

Enable experimental support for TC39 stage 2 draft decorators.

--explainFiles boolean

Print files read during the compilation including why it was included.

--extendedDiagnostics boolean


Output more detailed compiler performance information after building.

--forceConsistentCasingInFileNames boolean


Ensure that casing is correct in imports.

--generateCpuProfile string


Emit a v8 CPU profile of the compiler run for debugging.

--importHelpers boolean


Allow importing helper functions from tslib once per project, instead of including them per-file.

--importsNotUsedAsValues remove, preserve, or error

Specify emit/checking behavior for imports that are only used for types.

--incremental boolean

true if composite, false otherwise

Save .tsbuildinfo files to allow for incremental compilation of projects.

--inlineSourceMap boolean


Include sourcemap files inside the emitted JavaScript.

--inlineSources boolean


Include source code in the sourcemaps inside the emitted JavaScript.

--isolatedModules boolean


Ensure that each file can be safely transpiled without relying on other imports.

--jsx `react`, `react-jsx`, `react-jsxdev`, `react-native`, or `preserve`


Specify what JSX code is generated.

--jsxFactory string


Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'

--jsxFragmentFactory string

Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.

--jsxImportSource string


Specify module specifier used to import the JSX factory functions when using jsx: react-jsx*.`

--keyofStringsOnly boolean


Make keyof only return strings instead of string, numbers or symbols. Legacy option.

--lib list

Specify a set of bundled library declaration files that describe the target runtime environment.

--listEmittedFiles boolean


Print the names of emitted files after a compilation.

--listFiles boolean


Print all of the files read during the compilation.

--mapRoot string

Specify the location where debugger should locate map files instead of generated locations.

--maxNodeModuleJsDepth number


Specify the maximum folder depth used for checking JavaScript files from node_modules. Only applicable with allowJs.

--module `CommonJS` (default if `target` is `ES3` or `ES5`), , `ES6`, `ES2015`, `ES2020`, , `None`, `UMD`, `AMD`, `System`, or `ESNext`

Specify what module code is generated.


module === AMD or UMD or System or ES6, then Classic

Otherwise Node

Specify how TypeScript looks up a file from a given module specifier.


Platform specific

Set the newline character for emitting files.

--noEmit boolean


Disable emitting file from a compilation.

--noEmitHelpers boolean


Disable generating custom helper functions like __extends in compiled output.

--noEmitOnError boolean


Disable emitting files if any type checking errors are reported.

--noErrorTruncation boolean


Disable truncating types in error messages.

--noFallthroughCasesInSwitch boolean


Enable error reporting for fallthrough cases in switch statements.

--noImplicitAny boolean

false, unless strict is set

Enable error reporting for expressions and declarations with an implied any type..

--noImplicitOverride boolean

Ensure overriding members in derived classes are marked with an override modifier.

--noImplicitReturns boolean


Enable error reporting for codepaths that do not explicitly return in a function.

--noImplicitThis boolean

false, unless strict is set

Enable error reporting when this is given the type any.

--noImplicitUseStrict boolean


Disable adding 'use strict' directives in emitted JavaScript files.

--noLib boolean


Disable including any library files, including the default lib.d.ts.

--noPropertyAccessFromIndexSignature boolean


Enforces using indexed accessors for keys declared using an indexed type

--noResolve boolean


Disallow imports, requires or <reference>s from expanding the number of files TypeScript should add to a project.

--noStrictGenericChecks boolean


Disable strict checking of generic signatures in function types.

--noUncheckedIndexedAccess boolean

Add undefined to a type when accessed using an index.

--noUnusedLocals boolean


Enable error reporting when a local variables aren't read.

--noUnusedParameters boolean


Raise an error when a function parameter isn't read

--out string


Deprecated setting. Use outFile instead.

--outDir string


Specify an output folder for all emitted files.

--outFile 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.

--paths object

Specify a set of entries that re-map imports to additional lookup locations.

--plugins list

Specify a list of language service plugins to include.

--preserveConstEnums boolean


Disable erasing const enum declarations in generated code.

--preserveSymlinks boolean


Disable resolving symlinks to their realpath. This correlates to the same flag in node.

--preserveWatchOutput boolean


Disable wiping the console in watch mode

--pretty boolean


Enable color and formatting in output to make compiler errors easier to read

--reactNamespace string


Specify the object invoked for createElement. This only applies when targeting react JSX emit.

--removeComments boolean


Disable emitting comments.

--resolveJsonModule boolean


Enable importing .json files

--rootDir string

Computed from the list of input files

Specify the root folder within your source files.

--rootDirs list

Allow multiple folders to be treated as one when resolving modules.

--skipDefaultLibCheck boolean


Skip type checking .d.ts files that are included with TypeScript.

--skipLibCheck boolean


Skip type checking all .d.ts files.

--sourceMap boolean


Create source map files for emitted JavaScript files.

--sourceRoot string

Specify the root path for debuggers to find the reference source code.

--strict boolean


Enable all strict type checking options.

--strictBindCallApply boolean

false, unless strict is set

Check that the arguments for bind, call, and apply methods match the original function.

--strictFunctionTypes boolean

false, unless strict is set

When assigning functions, check to ensure parameters and the return values are subtype-compatible.

--strictNullChecks boolean

false, unless strict is set

When type checking, take into account null and undefined.

--strictPropertyInitialization boolean

false, unless strict is set

Check for class properties that are declared but not set in the constructor.

--stripInternal boolean

Disable emitting declarations that have @internal in their JSDoc comments.

--suppressExcessPropertyErrors boolean


Disable reporting of excess property errors during the creation of object literals.

--suppressImplicitAnyIndexErrors boolean


Suppress noImplicitAny errors when indexing objects that lack index signatures.

--target `ES3` (default), `ES5`, `ES6`/`ES2015` (synonymous), `ES7`/`ES2016`, `ES2017`, `ES2018`, `ES2019`, `ES2020`, or `ESNext`


Set the JavaScript language version for emitted JavaScript and include compatible library declarations.

--traceResolution boolean


Log paths used during the moduleResolution process.

--tsBuildInfoFile string


Specify the folder for .tsbuildinfo incremental compilation files.

--typeRoots list

Specify multiple folders that act like ./node_modules/@types.

--types list

Specify type package names to be included without being referenced in a source file.

--useDefineForClassFields boolean


Emit ECMAScript-standard-compliant class fields.

The TypeScript docs are an open source project. Help us improve these pages by sending a Pull Request

Contributors to this page:
MHMohamed Hegazy  (96)
OTOrta Therox  (39)
DRDaniel Rosenwasser  (19)
ADAxel D  (14)
AGAnton Gilgur  (7)

Last updated: Jun 16, 2021