Detailed tsconfig configuration of ts project

"compilerOptions": {

  "incremental": true, // The TS compiler will generate a file storing compilation information after the first compilation, and the second compilation will perform incremental compilation on the basis of the first compilation, which can improve the compilation speed

  "tsBuildInfoFile": "./buildFile", // storage location of incremental build file

  "diagnostics": true, // print diagnostic information 

  "target": "ES5", // version of target language

  "module": "CommonJS", // template standard for generated code

  "outFile": "./app.js", // Generate multiple interdependent files into one file, which can be used in the AMD module, that is, "module": "AMD" should be set when it is turned on,

  "lib": ["DOM", "ES2015", "ScriptHost", "ES2019.Array"], // The library that TS needs to reference, that is, the declaration file, es5 defaults to dom, es5, scripthost, if you need to use es Advanced version features usually need to be configured, such as the new array features of es8 need to introduce "ES2019.Array",

  "allowJS": true, // Allow the compiler to compile JS, JSX files

  "checkJs": true, // Allow errors in JS files, usually used together with allowJS

  "outDir": "./dist", // specify the output directory

  "rootDir": "./", // Specify the output file directory (for output), used to control the output directory structure

  "declaration": true, // Generate a declaration file, the declaration file will be automatically generated after opening

  "declarationDir": "./file", // Specify the directory where the generated declaration file is stored

  "emitDeclarationOnly": true, // only generate declaration files, not js files

  "sourceMap": true, // Generate the sourceMap file of the target file

  "inlineSourceMap": true, // generate the inline SourceMap of the target file, the inline SourceMap will be included in the generated js file

  "declarationMap": true, // generate sourceMap for the declaration file

  "typeRoots": [], // Declaration file directory, node_modules/@types by default

  "types": [], // loaded declaration file package

  "removeComments":true, // remove comments 

  "noEmit": true, // Do not output files, that is, no js files will be generated after compilation

  "noEmitOnError": true, // don't output any file when sending error

  "noEmitHelpers": true, // Do not generate helper functions, reduce size, require additional installation, often used together with importHelpers

  "importHelpers": true, // Import helper functions through tslib, the file must be a module

  "downlevelIteration": true, // Downgrade traverser implementation, if the target source is es3/5, then the traverser will have a downgrade implementation

  "strict": true, // enable all strict type checking

  "jsx": "preserve", // specify jsx format

  "alwaysStrict": true, // inject 'use strict' into the code

  "noImplicitAny": true, // does not allow implicit any type

  "strictNullChecks": true, // It is not allowed to assign null and undefined to other types of variables

  "strictFunctionTypes": true, // do not allow bidirectional covariance of function parameters

  "strictPropertyInitialization": true, // instance properties of the class must be initialized

  "strictBindCallApply": true, // strict bind/call/apply check

  "noImplicitThis": true, // does not allow this to have an implicit any type

  "noUnusedLocals": true, // Check only declared, unused local variables (only prompts and no errors)

  "noUnusedParameters": true, // Check for unused function parameters (only prompts and no errors)

  "noFallthroughCasesInSwitch": true, // Prevent the switch statement from passing through (that is, it will not be executed if there is no break statement)

  "noImplicitReturns": true, //Each branch will have a return value

  "esModuleInterop": true, // allow export=export, imported by import from

  "allowUmdGlobalAccess": true, // Allow access to the umd module as a global variable in the module

  "moduleResolution": "node", // module resolution strategy, ts uses node resolution strategy by default, that is, relative import

  "baseUrl": "./", // resolve the base address of non-relative modules, the default is the current directory

  "paths": { // path mapping, relative to baseUrl

    // If you don't want to use the default version when using jq, but need to manually specify the version, you can configure it as follows

    "jquery": ["node_modules/jquery/dist/jquery.min.js"]

  },

  "rootDirs": ["src","out"], // Put multiple directories under a virtual directory for runtime, that is, the location of imported files after compilation may change, which can also set virtual src and out is in the same directory, no need to change the path and no error will be reported

  "listEmittedFiles": true, // print output files

  "listFiles": true// Print compiled files (including referenced declaration files)

}

Guess you like

Origin blog.csdn.net/qq_44476091/article/details/125635093