tsc CLI Options

Using the CLI

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.


# Run a compile based on a backwards look through the fs for a tsconfig.json

tsc

# 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 ↗](https://www.typescriptlang.org/tsconfig.html#force) boolean
Build all projects, including those that appear to be up to date.
[--verbose ↗](https://www.typescriptlang.org/tsconfig.html#verbose) boolean
Enable verbose logging.

Watch Options

Flag Type
[--excludeDirectories ↗](https://www.typescriptlang.org/tsconfig.html#excludeDirectories) list
Remove a list of directories from the watch process.
[--excludeFiles ↗](https://www.typescriptlang.org/tsconfig.html#excludeFiles) list
Remove a list of files from the watch mode’s processing.
[--fallbackPolling ↗](https://www.typescriptlang.org/tsconfig.html#fallbackPolling) fixedinterval, priorityinterval, dynamicpriority, or fixedchunksize
Specify what approach the watcher should use if the system runs out of native file watchers.
[--synchronousWatchDirectory ↗](https://www.typescriptlang.org/tsconfig.html#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 ↗](https://www.typescriptlang.org/tsconfig.html#watchDirectory) usefsevents, fixedpollinginterval, dynamicprioritypolling, or fixedchunksizepolling
Specify how directories are watched on systems that lack recursive file-watching functionality.
[--watchFile ↗](https://www.typescriptlang.org/tsconfig.html#watchFile) fixedpollinginterval, prioritypollinginterval, dynamicprioritypolling, fixedchunksizepolling, usefsevents, or usefseventsonparentdirectory
Specify how the TypeScript watch mode works.

Compiler Flags

Flag Type Default
[--allowArbitraryExtensions ↗](https://www.typescriptlang.org/tsconfig.html#allowArbitraryExtensions) boolean
false
Enable importing files with any extension, provided a declaration file is present.
[--allowImportingTsExtensions ↗](https://www.typescriptlang.org/tsconfig.html#allowImportingTsExtensions) boolean
false
Allow imports to include TypeScript file extensions.
[--allowJs ↗](https://www.typescriptlang.org/tsconfig.html#allowJs) boolean
false
Allow JavaScript files to be a part of your program. Use the checkJS option to get errors from these files.
[--allowSyntheticDefaultImports ↗](https://www.typescriptlang.org/tsconfig.html#allowSyntheticDefaultImports) boolean
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.
[--allowUmdGlobalAccess ↗](https://www.typescriptlang.org/tsconfig.html#allowUmdGlobalAccess) boolean
false
Allow accessing UMD globals from modules.
[--allowUnreachableCode ↗](https://www.typescriptlang.org/tsconfig.html#allowUnreachableCode) boolean
Disable error reporting for unreachable code.
[--allowUnusedLabels ↗](https://www.typescriptlang.org/tsconfig.html#allowUnusedLabels) boolean
Disable error reporting for unused labels.
[--alwaysStrict ↗](https://www.typescriptlang.org/tsconfig.html#alwaysStrict) boolean
true if strict; false otherwise.
Ensure ‘use strict’ is always emitted.
[--assumeChangesOnlyAffectDirectDependencies ↗](https://www.typescriptlang.org/tsconfig.html#assumeChangesOnlyAffectDirectDependencies) boolean
false
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 ↗](https://www.typescriptlang.org/tsconfig.html#baseUrl) string
Specify the base directory to resolve bare specifier module names.
[--charset ↗](https://www.typescriptlang.org/tsconfig.html#charset) string
utf8
No longer supported. In early versions, manually set the text encoding for reading files.
[--checkJs ↗](https://www.typescriptlang.org/tsconfig.html#checkJs) boolean
false
Enable error reporting in type-checked JavaScript files.
[--composite ↗](https://www.typescriptlang.org/tsconfig.html#composite) boolean
false
Enable constraints that allow a TypeScript project to be used with project references.
[--customConditions ↗](https://www.typescriptlang.org/tsconfig.html#customConditions) list
Conditions to set in addition to the resolver-specific defaults when resolving imports.
[--declaration ↗](https://www.typescriptlang.org/tsconfig.html#declaration) boolean
true if composite; false otherwise.
Generate .d.ts files from TypeScript and JavaScript files in your project.
[--declarationDir ↗](https://www.typescriptlang.org/tsconfig.html#declarationDir) string
Specify the output directory for generated declaration files.
[--declarationMap ↗](https://www.typescriptlang.org/tsconfig.html#declarationMap) boolean
false
Create sourcemaps for d.ts files.
[--diagnostics ↗](https://www.typescriptlang.org/tsconfig.html#diagnostics) boolean
false
Output compiler performance information after building.
[--disableReferencedProjectLoad ↗](https://www.typescriptlang.org/tsconfig.html#disableReferencedProjectLoad) boolean
false
Reduce the number of projects loaded automatically by TypeScript.
[--disableSizeLimit ↗](https://www.typescriptlang.org/tsconfig.html#disableSizeLimit) boolean
false
Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.
[--disableSolutionSearching ↗](https://www.typescriptlang.org/tsconfig.html#disableSolutionSearching) boolean
false
Opt a project out of multi-project reference checking when editing.
[--disableSourceOfProjectReferenceRedirect ↗](https://www.typescriptlang.org/tsconfig.html#disableSourceOfProjectReferenceRedirect) boolean
false
Disable preferring source files instead of declaration files when referencing composite projects.
[--downlevelIteration ↗](https://www.typescriptlang.org/tsconfig.html#downlevelIteration) boolean
false
Emit more compliant, but verbose and less performant JavaScript for iteration.
[--emitBOM ↗](https://www.typescriptlang.org/tsconfig.html#emitBOM) boolean
false
Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
[--emitDeclarationOnly ↗](https://www.typescriptlang.org/tsconfig.html#emitDeclarationOnly) boolean
false
Only output d.ts files and not JavaScript files.
[--emitDecoratorMetadata ↗](https://www.typescriptlang.org/tsconfig.html#emitDecoratorMetadata) boolean
false
Emit design-type metadata for decorated declarations in source files.
[--esModuleInterop ↗](https://www.typescriptlang.org/tsconfig.html#esModuleInterop) boolean
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.
[--exactOptionalPropertyTypes ↗](https://www.typescriptlang.org/tsconfig.html#exactOptionalPropertyTypes) boolean
false
Interpret optional property types as written, rather than adding undefined.
[--experimentalDecorators ↗](https://www.typescriptlang.org/tsconfig.html#experimentalDecorators) boolean
false
Enable experimental support for TC39 stage 2 draft decorators.
[--explainFiles ↗](https://www.typescriptlang.org/tsconfig.html#explainFiles) boolean
false
Print files read during the compilation including why it was included.
[--extendedDiagnostics ↗](https://www.typescriptlang.org/tsconfig.html#extendedDiagnostics) boolean
false
Output more detailed compiler performance information after building.
[--forceConsistentCasingInFileNames ↗](https://www.typescriptlang.org/tsconfig.html#forceConsistentCasingInFileNames) boolean
true
Ensure that casing is correct in imports.
[--generateCpuProfile ↗](https://www.typescriptlang.org/tsconfig.html#generateCpuProfile) string
profile.cpuprofile
Emit a v8 CPU profile of the compiler run for debugging.
[--importHelpers ↗](https://www.typescriptlang.org/tsconfig.html#importHelpers) boolean
false
Allow importing helper functions from tslib once per project, instead of including them per-file.
[--importsNotUsedAsValues ↗](https://www.typescriptlang.org/tsconfig.html#importsNotUsedAsValues) remove, preserve, or error
remove
Specify emit/checking behavior for imports that are only used for types.
[--incremental ↗](https://www.typescriptlang.org/tsconfig.html#incremental) boolean
true if composite; false otherwise.
Save .tsbuildinfo files to allow for incremental compilation of projects.
[--inlineSourceMap ↗](https://www.typescriptlang.org/tsconfig.html#inlineSourceMap) boolean
false
Include sourcemap files inside the emitted JavaScript.
[--inlineSources ↗](https://www.typescriptlang.org/tsconfig.html#inlineSources) boolean
false
Include source code in the sourcemaps inside the emitted JavaScript.
[--isolatedModules ↗](https://www.typescriptlang.org/tsconfig.html#isolatedModules) boolean
false
Ensure that each file can be safely transpiled without relying on other imports.
[--jsx ↗](https://www.typescriptlang.org/tsconfig.html#jsx) preserve, react, react-native, react-jsx, or react-jsxdev
Specify what JSX code is generated.
[--jsxFactory ↗](https://www.typescriptlang.org/tsconfig.html#jsxFactory) string
React.createElement
Specify the JSX factory function used when targeting React JSX emit, e.g. ‘React.createElement’ or ‘h’.
[--jsxFragmentFactory ↗](https://www.typescriptlang.org/tsconfig.html#jsxFragmentFactory) string
React.Fragment
Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. ‘React.Fragment’ or ‘Fragment’.
[--jsxImportSource ↗](https://www.typescriptlang.org/tsconfig.html#jsxImportSource) string
react
Specify module specifier used to import the JSX factory functions when using jsx: react-jsx*.
[--keyofStringsOnly ↗](https://www.typescriptlang.org/tsconfig.html#keyofStringsOnly) boolean
false
Make keyof only return strings instead of string, numbers or symbols. Legacy option.
[--lib ↗](https://www.typescriptlang.org/tsconfig.html#lib) list
Specify a set of bundled library declaration files that describe the target runtime environment.
[--listEmittedFiles ↗](https://www.typescriptlang.org/tsconfig.html#listEmittedFiles) boolean
false
Print the names of emitted files after a compilation.
[--listFiles ↗](https://www.typescriptlang.org/tsconfig.html#listFiles) boolean
false
Print all of the files read during the compilation.
[--mapRoot ↗](https://www.typescriptlang.org/tsconfig.html#mapRoot) string
Specify the location where debugger should locate map files instead of generated locations.
[--maxNodeModuleJsDepth ↗](https://www.typescriptlang.org/tsconfig.html#maxNodeModuleJsDepth) number
0
Specify the maximum folder depth used for checking JavaScript files from node_modules. Only applicable with allowJs.
[--module ↗](https://www.typescriptlang.org/tsconfig.html#module) 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.
[--moduleDetection ↗](https://www.typescriptlang.org/tsconfig.html#moduleDetection) legacy, auto, or force
“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.
[--moduleResolution ↗](https://www.typescriptlang.org/tsconfig.html#moduleResolution) 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.
[--moduleSuffixes ↗](https://www.typescriptlang.org/tsconfig.html#moduleSuffixes) list
List of file name suffixes to search when resolving a module.
[--newLine ↗](https://www.typescriptlang.org/tsconfig.html#newLine) crlf or lf
Platform specific.
Set the newline character for emitting files.
[--noEmit ↗](https://www.typescriptlang.org/tsconfig.html#noEmit) boolean
false
Disable emitting files from a compilation.
[--noEmitHelpers ↗](https://www.typescriptlang.org/tsconfig.html#noEmitHelpers) boolean
false
Disable generating custom helper functions like __extends in compiled output.
[--noEmitOnError ↗](https://www.typescriptlang.org/tsconfig.html#noEmitOnError) boolean
false
Disable emitting files if any type checking errors are reported.
[--noErrorTruncation ↗](https://www.typescriptlang.org/tsconfig.html#noErrorTruncation) boolean
false
Disable truncating types in error messages.
[--noFallthroughCasesInSwitch ↗](https://www.typescriptlang.org/tsconfig.html#noFallthroughCasesInSwitch) boolean
false
Enable error reporting for fallthrough cases in switch statements.
[--noImplicitAny ↗](https://www.typescriptlang.org/tsconfig.html#noImplicitAny) boolean
true if strict; false otherwise.
Enable error reporting for expressions and declarations with an implied any type.
[--noImplicitOverride ↗](https://www.typescriptlang.org/tsconfig.html#noImplicitOverride) boolean
false
Ensure overriding members in derived classes are marked with an override modifier.
[--noImplicitReturns ↗](https://www.typescriptlang.org/tsconfig.html#noImplicitReturns) boolean
false
Enable error reporting for codepaths that do not explicitly return in a function.
[--noImplicitThis ↗](https://www.typescriptlang.org/tsconfig.html#noImplicitThis) boolean
true if strict; false otherwise.
Enable error reporting when this is given the type any.
[--noImplicitUseStrict ↗](https://www.typescriptlang.org/tsconfig.html#noImplicitUseStrict) boolean
false
Disable adding ‘use strict’ directives in emitted JavaScript files.
[--noLib ↗](https://www.typescriptlang.org/tsconfig.html#noLib) boolean
false
Disable including any library files, including the default lib.d.ts.
[--noPropertyAccessFromIndexSignature ↗](https://www.typescriptlang.org/tsconfig.html#noPropertyAccessFromIndexSignature) boolean
false
Enforces using indexed accessors for keys declared using an indexed type.
[--noResolve ↗](https://www.typescriptlang.org/tsconfig.html#noResolve) boolean
false
Disallow imports, requires or <reference>s from expanding the number of files TypeScript should add to a project.
[--noStrictGenericChecks ↗](https://www.typescriptlang.org/tsconfig.html#noStrictGenericChecks) boolean
false
Disable strict checking of generic signatures in function types.
[--noUncheckedIndexedAccess ↗](https://www.typescriptlang.org/tsconfig.html#noUncheckedIndexedAccess) boolean
false
Add undefined to a type when accessed using an index.
[--noUnusedLocals ↗](https://www.typescriptlang.org/tsconfig.html#noUnusedLocals) boolean
false
Enable error reporting when local variables aren’t read.
[--noUnusedParameters ↗](https://www.typescriptlang.org/tsconfig.html#noUnusedParameters) boolean
false
Raise an error when a function parameter isn’t read.
[--out ↗](https://www.typescriptlang.org/tsconfig.html#out) string
Deprecated setting. Use outFile instead.
[--outDir ↗](https://www.typescriptlang.org/tsconfig.html#outDir) string
Specify an output folder for all emitted files.
[--outFile ↗](https://www.typescriptlang.org/tsconfig.html#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 ↗](https://www.typescriptlang.org/tsconfig.html#paths) object
Specify a set of entries that re-map imports to additional lookup locations.
[--plugins ↗](https://www.typescriptlang.org/tsconfig.html#plugins) list
Specify a list of language service plugins to include.
[--preserveConstEnums ↗](https://www.typescriptlang.org/tsconfig.html#preserveConstEnums) boolean
true if isolatedModules; false otherwise.
Disable erasing const enum declarations in generated code.
[--preserveSymlinks ↗](https://www.typescriptlang.org/tsconfig.html#preserveSymlinks) boolean
false
Disable resolving symlinks to their realpath. This correlates to the same flag in node.
[--preserveValueImports ↗](https://www.typescriptlang.org/tsconfig.html#preserveValueImports) boolean
false
Preserve unused imported values in the JavaScript output that would otherwise be removed.
[--preserveWatchOutput ↗](https://www.typescriptlang.org/tsconfig.html#preserveWatchOutput) boolean
false
Disable wiping the console in watch mode.
[--pretty ↗](https://www.typescriptlang.org/tsconfig.html#pretty) boolean
true
Enable color and formatting in TypeScript’s output to make compiler errors easier to read.
[--reactNamespace ↗](https://www.typescriptlang.org/tsconfig.html#reactNamespace) string
React
Specify the object invoked for createElement. This only applies when targeting react JSX emit.
[--removeComments ↗](https://www.typescriptlang.org/tsconfig.html#removeComments) boolean
false
Disable emitting comments.
[--resolveJsonModule ↗](https://www.typescriptlang.org/tsconfig.html#resolveJsonModule) boolean
false
Enable importing .json files.
[--resolvePackageJsonExports ↗](https://www.typescriptlang.org/tsconfig.html#resolvePackageJsonExports) boolean
true when moduleResolution is node16, nodenext, or bundler; otherwise false
Use the package.json ’exports’ field when resolving package imports.
[--resolvePackageJsonImports ↗](https://www.typescriptlang.org/tsconfig.html#resolvePackageJsonImports) boolean
true when moduleResolution is node16, nodenext, or bundler; otherwise false
Use the package.json ‘imports’ field when resolving imports.
[--rootDir ↗](https://www.typescriptlang.org/tsconfig.html#rootDir) string
Computed from the list of input files.
Specify the root folder within your source files.
[--rootDirs ↗](https://www.typescriptlang.org/tsconfig.html#rootDirs) list
Computed from the list of input files.
Allow multiple folders to be treated as one when resolving modules.
[--skipDefaultLibCheck ↗](https://www.typescriptlang.org/tsconfig.html#skipDefaultLibCheck) boolean
false
Skip type checking .d.ts files that are included with TypeScript.
[--skipLibCheck ↗](https://www.typescriptlang.org/tsconfig.html#skipLibCheck) boolean
false
Skip type checking all .d.ts files.
[--sourceMap ↗](https://www.typescriptlang.org/tsconfig.html#sourceMap) boolean
false
Create source map files for emitted JavaScript files.
[--sourceRoot ↗](https://www.typescriptlang.org/tsconfig.html#sourceRoot) string
Specify the root path for debuggers to find the reference source code.
[--strict ↗](https://www.typescriptlang.org/tsconfig.html#strict) boolean
false
Enable all strict type-checking options.
[--strictBindCallApply ↗](https://www.typescriptlang.org/tsconfig.html#strictBindCallApply) boolean
true if strict; false otherwise.
Check that the arguments for bind, call, and apply methods match the original function.
[--strictFunctionTypes ↗](https://www.typescriptlang.org/tsconfig.html#strictFunctionTypes) boolean
true if strict; false otherwise.
When assigning functions, check to ensure parameters and the return values are subtype-compatible.
[--strictNullChecks ↗](https://www.typescriptlang.org/tsconfig.html#strictNullChecks) boolean
true if strict; false otherwise.
When type checking, take into account null and undefined.
[--strictPropertyInitialization ↗](https://www.typescriptlang.org/tsconfig.html#strictPropertyInitialization) boolean
true if strict; false otherwise.
Check for class properties that are declared but not set in the constructor.
[--stripInternal ↗](https://www.typescriptlang.org/tsconfig.html#stripInternal) boolean
false
Disable emitting declarations that have @internal in their JSDoc comments.
[--suppressExcessPropertyErrors ↗](https://www.typescriptlang.org/tsconfig.html#suppressExcessPropertyErrors) boolean
false
Disable reporting of excess property errors during the creation of object literals.
[--suppressImplicitAnyIndexErrors ↗](https://www.typescriptlang.org/tsconfig.html#suppressImplicitAnyIndexErrors) boolean
false
Suppress noImplicitAny errors when indexing objects that lack index signatures.
[--target ↗](https://www.typescriptlang.org/tsconfig.html#target) es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, or esnext
ES3
Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
[--traceResolution ↗](https://www.typescriptlang.org/tsconfig.html#traceResolution) boolean
false
Log paths used during the moduleResolution process.
[--tsBuildInfoFile ↗](https://www.typescriptlang.org/tsconfig.html#tsBuildInfoFile) string
.tsbuildinfo
The file to store .tsbuildinfo incremental build information in.
[--typeRoots ↗](https://www.typescriptlang.org/tsconfig.html#typeRoots) list
Specify multiple folders that act like ./node_modules/@types.
[--types ↗](https://www.typescriptlang.org/tsconfig.html#types) list
Specify type package names to be included without being referenced in a source file.
[--useDefineForClassFields ↗](https://www.typescriptlang.org/tsconfig.html#useDefineForClassFields) boolean
true if target is ES2022 or higher, including ESNext; false otherwise.
Emit ECMAScript-standard-compliant class fields.
[--useUnknownInCatchVariables ↗](https://www.typescriptlang.org/tsconfig.html#useUnknownInCatchVariables) boolean
true if strict; false otherwise.
Default catch clause variables as unknown instead of any.
[--verbatimModuleSyntax ↗](https://www.typescriptlang.org/tsconfig.html#verbatimModuleSyntax) boolean
false
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.

Related

Last updated on