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, or a path to a valid .json file containing the configurations.

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

Examples

Example tsconfig.json files:

  • Using the "files" property

    1. json
      {
    2. "compilerOptions": {
    3. "module": "commonjs",
    4. "noImplicitAny": true,
    5. "removeComments": true,
    6. "preserveConstEnums": true,
    7. "sourceMap": true
    8. },
    9. "files": [
    10. "core.ts",
    11. "sys.ts",
    12. "types.ts",
    13. "scanner.ts",
    14. "parser.ts",
    15. "utilities.ts",
    16. "binder.ts",
    17. "checker.ts",
    18. "emitter.ts",
    19. "program.ts",
    20. "commandLineParser.ts",
    21. "tsc.ts",
    22. "diagnosticInformationMap.generated.ts"
    23. ]
    24. }
  • Using the "include" and "exclude" properties

    1. json
      {
    2. "compilerOptions": {
    3. "module": "system",
    4. "noImplicitAny": true,
    5. "removeComments": true,
    6. "preserveConstEnums": true,
    7. "outFile": "../../built/local/tsc.js",
    8. "sourceMap": true
    9. },
    10. "include": ["src/**/*"],
    11. "exclude": ["node_modules", "**/*.spec.ts"]
    12. }

Details

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

TSConfig Reference

To learn more about the hundreds of configuration options in the TSConfig Reference.

Schema

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