当前位置:网站首页>Typescript compilation options and configuration files

Typescript compilation options and configuration files

2022-06-11 11:41:00 Michael18811380328

typescript Compile options and configuration files

Use TS When the front-end project is completed , It's usually necessary to put TS Compiled into different versions JS, Then use it with other files .

Profile description

Configuration items are placed in tsconfig.json in , It mainly includes the following configurations

*  Yes  tsconfig.json  The directory of the file is a  Typescript  project 
* tsc  No input file 
: Look up from the current position  tsconfig.json
:--project  Catalog ( contain  tsconfig.json) | .json  file 
*  If there is an input file, ignore  tsconfig.json
*  attribute  files: Files to compile 
*  attribute  include: Included files 
*  attribute  exclude: Excluded documents 
*  attribute  compilerOptions: Compilation options 
* glob-like file patterns, Water drop mode 
  :* =  Zero or more characters ( Do not include directory separator )
  :? =  A character 
  :**/ =  Recursively match subdirectories 
  :(* or .*) matching  .ts, .tsx, .d.ts  and  .jsx(allowJs = true*  Is not specified  files  and  include: In the current directory and subdirectories  typescript  file 
*  At the same time specified  files  and  include: Union and collection 
*  Is not specified  exclude, Exclude by default  outDir
* exclude  Can be ruled out  include, Cannot be excluded  files
* exclude  Default  node_modules, bower_components, jspm_packages and <outDir>
*  The referenced documents will also be included 
*  It is possible that input files will not be included , It is not recommended to use a file with the same name ( Different extensions )
* tsconfig.json  Empty can also 
*  Command line options take precedence 
* node_modules/@types  Will be included , And so on 
* typeRoots  Restricted the root directory 
* types  If you are , Only those specified will be included  ./node_modules/@types/node ...* type package1) Yes  index.d.ts  Folder ;2package.json that has a types field
*  Auto include only in   Global declarations   It's important , Use  import  Unwanted 
*  attribute  extends  You can inherit the configuration 
* extends  Is a top-level attribute , The value is   Path to another configuration file 
*  Local configuration overrides inherited configuration , If you inherit from each other, you will report an error 
*  The path is relative to each configuration file 
* compileOnSave: Top attributes , At present, only for  VS2015 The above is effective 

Description of compilation options

Compilation options , It refers to the compilation process , How to operate

typescript  Compilation options 
-- allowJs = false:js Files are also compiled 
-- allowUnreachableCode = false: Do you want to report an error for the code that is impossible to execute 
-- allowUnusedLabels = false: Not used  label  Do you want to report an error 
-- alwaysStrict = false: Parse and output in strict mode 
-- build = false: Produce current projects and dependent projects 
-- charset = "utf-8": Input the character set of the file 
-- checkJs = false:js Do you want to report the error of the file 
-- declaration = false: Generate corresponding  .d.ts  file 
-- declarationDir = null: Where to put the declaration file 
-- declarationMap = false: Production declaration document  sourcemap
-- diagnostics = false: Display diagnostic information 
-- disableSizeLimit = false: Remove the item size limit 
-- downlevelIteration = false: oriented  ES5  and  ES3  when , take  for..of, spread and destructuring   Downgrade 
-- emitBOM = false: The input file code is with BOM
-- emitDeclarationOnly = false: Output only the declaration file 
-- forceConsistentCasingInFileNames = false: Enforce file name case consistency 
-- help: help 
-- inlineSources = false: inline  sourcemap
-- inlineSources = false: Inline source code , It needs to be set at the same time  inlineSources  and  sourcemap
-- init: Initialize a project 
-- isolatedModules = false: Each file is a separate module 
-- jsx = "Preserve":jsx Processing mode 
-- jsxFactory = "React.createElement":jsx  The factory method of 
-- keyofStringsOnly = false:keyof  Use only string keys to parse 
-- lib: Libraries to use when compiling 
:ES5: DOM,ES5,ScriptHost
:ES6: DOM,ES6,DOM.Iterable,ScriptHost
-- listEmittedFiles = false: List the generated file names 
-- listFiles = false: List the generated file names 
-- locale: Error message language 
-- module: How to generate module code 
		:"None", "CommonJS", "AMD", "System", "UMD", "ES6", "ES2015" or "ESNext".
-- watch: Keep an eye on the input file 
-- target = "ES3": Target criteria 
		:"ES3" (default), "ES5", "ES6"/"ES2015", "ES2016", "ES2017" or "ESNext". 
-- showConfig = false: Only the configuration 
-- removeComments = fasle: Remove comments 
-- project: Specify profile 
-- pretty = true: Beautify the output 
--preserveConstEnums = false: Keep constant and enumeration declarations 
--noEmit: Don't output 
--noEmitOnError: Do not output when there is an error 
原网站

版权声明
本文为[Michael18811380328]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111128511173.html