TypeScript Compile Options

满元凯
2023-12-01

Compile Options

1. -w, --watch

Watch input files.

Run the compiler in monitor mode. The output files will be monitored, and when source files changes, they will be recompiled automatically.

# monitor test.ts
tsc -w test.ts

# monitor every files
tsc -w

2. tsconfig.json Configuration File

tsconfig.json is the configuration file of TypeScript compiler. TypeScript compiler will compile the code according to the information in the configuration file.

{
    // tsconfig.json is the configuration file of TypeScript compiler. 
    // TypeScript compiler will compile the code according to the information in the configuration file.
    // include: need to compile
    "include": [
        "./**/*"
    ],
    // exclude: need not to compile
    "exclude": [
        ""
    ],
    // compiler option
    "compilerOptions": {
        // compile target: Specify an ES version
        "target": "ES2015",
        // Specify the version of the modular specification.
        // "module": "es2015",
        // Specify library your project use
        "lib": [
            "ES6",
            "DOM"
        ],
        // outDir: Specify the directory of the compiled file.
        "outDir": "./dist",
        // outFile: Merge the code into one file.
        "outFile": "./dist/app.js",
        // allow JS: Whether to compile JS file.
        "allowJs": false,
        // checkJs: Whether to check JS grammar.
        "checkJs": false,
        // removeComments: Whether to remove comments.
        "removeComments": false,
        // Do not generate compiled file.
        "noEmit": false,
        // Do not generate compiled file when has error.
        "noEmitOnError": true,
        // Whether to open All Strict Mode, including the following four.
        "strict": true,
        // - Whether to use Strict Mode always.
        "alwaysStrict": true,
        // - Whether to don't allow to use 'any' implicitly.
        "noImplicitAny": true,
        // - Whether to don't allow to use 'this' implicitly.
        "noImplicitThis": true,
        // - Whether to check null value strictly.
        "strictNullChecks": true,
    }
}
 类似资料:

相关阅读

相关文章

相关问答