Overview

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. A project is compiled in one of the following ways:

Using tsconfig.json

  • 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 a tsconfig.json file.

When input files are specified on the command line, tsconfig.json files are ignored.

Examples

Example tsconfig.json files:

  • Using the "files" property

    {
      "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../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 "include" and "exclude" properties

    {
      "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../built/local/tsc.js",
        "sourceMap": true
      },
      "include": [
        "src/**/*"
      ],
      "exclude": [
        "node_modules",
        "**/*.spec.ts"
      ]
    }
    

Details

The "compilerOptions" property can be omitted, in which case the compiler’s defaults are used. See our full list of supported Compiler Options.

The "files" property takes a list of relative or absolute file paths. The "include" and "exclude" properties take a list of glob-like file patterns. The supported glob wildcards are:

  • * matches zero or more characters (excluding directory separators)
  • ? matches any one character (excluding directory separators)
  • **/ recursively matches any subdirectory

If a segment of a glob pattern includes only * or .*, then only files with supported extensions are included (e.g. .ts, .tsx, and .d.ts by default with .js and .jsx if allowJs is set to true).

If the "files" and "include" are both left unspecified, the compiler defaults to including all TypeScript (.ts, .d.ts and .tsx) files in the containing directory and subdirectories except those excluded using the "exclude" property. JS files (.js and .jsx) are also included if allowJs is set to true. If the "files" or "include" properties are specified, the compiler will instead include the union of the files included by those two properties. Files in the directory specified using the "outDir" compiler option are always excluded unless explicitly included via the "files" property (even when the “exclude” property is specified).

Files included using "include" can be filtered using the "exclude" property. However, files included explicitly using the "files" property are always included regardless of "exclude". The "exclude" property defaults to excluding the node_modules, bower_components, and jspm_packages directories when not specified.

Any files that are referenced by files included via the "files" or "include" properties 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 included by default (as described above) with the default compiler options.

Compiler options specified on the command line override those specified in the tsconfig.json file.

compileOnSave

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

Schema can be found at: http://json.schemastore.org/tsconfig

Schema

Schema Schema can be found at: http://json.schemastore.org/tsconfig

2016-10-04 19:25:33
Details

Details The "compilerOptions" property can be omitted, in which case the compiler’s defaults are used. See our full list of supported

2016-10-04 19:25:10
Browserify

Browserify

2016-10-04 19:25:03
Grunt

Grunt

2016-10-04 19:25:16
NuGet

NuGet Right-Click -> Manage NuGet Packages Search for Microsoft.TypeScript.MSBuild Hit Install

2016-10-04 19:25:27
Using npm

Using npm npm install -g typescript@next

2016-10-04 19:25:43
compileOnSave

compileOnSave Setting a top-level property compileOnSave signals to the IDE to generate all files for a given tsconfig

2016-10-04 19:25:05
Duo

Duo

2016-10-04 19:25:11
TypeScriptCompileBlocked

TypeScriptCompileBlocked If you are using a different build tool to build your project (e.g. gulp, grunt , etc.) and VS for the development

2016-10-04 19:25:41
jspm

jspm

2016-10-04 19:25:21