-
Notifications
You must be signed in to change notification settings - Fork 12.5k
tsconfig.json
The presence of a tsconfig.json
file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json
file specifies the root files and the compiler options required to compile the project. tsconfig.json
is supported starting with TypeScript 1.5. A project is compiled in one of the following ways:
- By invoking tsc with no input files, in which case the compiler searches for the
tsconfig.json
file starting in the current directory and continuing up the parent directory chain. - By invoking tsc with no input files and a
-project
(or just-p
) command line option that specifies the path of a directory containing atsconfig.json
file.
When input files are specified on the command line, tsconfig.json
files are ignored.
Example tsconfig.json
files:
- Using the
"files"
property
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"out": "../../built/local/tsc.js",
"sourceMap": true
},
"files": [
"core.ts",
"sys.ts",
"types.ts",
"scanner.ts",
"parser.ts",
"utilities.ts",
"binder.ts",
"checker.ts",
"emitter.ts",
"program.ts",
"commandLineParser.ts",
"tsc.ts",
"diagnosticInformationMap.generated.ts"
]
}
- Using the
"exclude"
property
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"out": "../../built/local/tsc.js",
"sourceMap": true
},
"exclude": [
"node_modules",
"wwwroot"
]
}
The "compilerOptions"
property can be omitted, in which case the compiler's defaults are used. See our full list of supported Compiler Options.
If no "files"
property is present in a tsconfig.json
, the compiler defaults to including all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories. When a "files"
property is present, only the specified files are included.
If the "exclude"
property is specified, the compiler includes all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories except for those files or folders that are excluded.
The "files"
property cannot be used in conjunction with the "exclude"
property. If both are specified then the "files"
property takes precedence.
Any files that are referenced by those specified in the "files"
property are also included.
Similarly, if a file B.ts
is referenced by another file A.ts
, then B.ts
cannot be excluded unless the referencing file A.ts
is also specified in the "exclude"
list.
A tsconfig.json
file is permitted to be completely empty, which compiles all files in the containing directory and subdirectories with the default compiler options.
Compiler options specified on the command line override those specified in the tsconfig.json
file.
Setting a top-level property compileOnSave
signals to the IDE to generate all files for a given tsconfig.json upon saving.
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny" : true
}
}
This feature is currently supported in Visual Studio 2015 with TypeScript 1.8.4 and above, and atom-typescript plugin.
Schema can be found at: http://json.schemastore.org/tsconfig
News
Debugging TypeScript
- Performance
- Performance-Tracing
- Debugging-Language-Service-in-VS-Code
- Getting-logs-from-TS-Server-in-VS-Code
- JavaScript-Language-Service-in-Visual-Studio
- Providing-Visual-Studio-Repro-Steps
Contributing to TypeScript
- Contributing to TypeScript
- TypeScript Design Goals
- Coding Guidelines
- Useful Links for TypeScript Issue Management
- Writing Good Design Proposals
- Compiler Repo Notes
- Deployment
Building Tools for TypeScript
- Architectural Overview
- Using the Compiler API
- Using the Language Service API
- Standalone Server (tsserver)
- TypeScript MSBuild In Depth
- Debugging Language Service in VS Code
- Writing a Language Service Plugin
- Docker Quickstart
FAQs
The Main Repo