1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| // tsconfig.json { "compilerOptions": { /*=== Basic Options 基础编译选项 ===*/ // "incremental": true, /* Enable incremental compilation */ "target": "ES5", /* 编译完之后的ECMAScript 目标版本: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. 但是新的内置对象、静态方法、实例方法等不转换 */ "module": "ESNext", /* 使用怎样的模块形式输出: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ "allowJs": true, // default:false 允许编译javascript文件。 // "checkJs": true, /* Report errors in .js files. */ "jsx": "preserve", // Default :"preserve"在 .tsx文件里支持JSX 在preserve模式下生成代码中会保留JSX以供后续的转换操作使用(比如:Babel) "react" 转换成React. "declaration": true, /* 为每一个ts文件生成'.d.ts' 文件. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "build", /* 输出目录 */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "isolatedModules": true, /* 文件必须以模块的形式组织 */
/*=== Strict Type-Checking Options 严格模式检查 ===*/ "strict": true, /* default:false 启用所有严格类型检查选项。相当于全部启用下面这些 */ // "noImplicitAny": true, /* 不能有隐式的any类型 */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/*=== Additional Checks 一些格式检查===*/ // "noUnusedLocals": true, /* Report errors on unused locals. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/*=== Module Resolution Options 模块相关的一些方案===*/ "moduleResolution": "node", /* 指定模块解析策略为node 否则会绝对路径去找找不到: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ "allowSyntheticDefaultImports": true, /* 允许使用 import React from "react"; 否则要写成:import * as React from "react"; */ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/*=== Source Map Options source map配置===*/ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/*=== Experimental Options 实验性选项支持 ===*/ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Default:false 启用实验性的ES装饰器。 */
/*=== Advanced Options 高级选项 ===*/ "forceConsistentCasingInFileNames": true, /* Default:false 禁止对同一个文件的不一致的引用 */ // "skipLibCheck": false, /* default:false 忽略所有的声明文件( *.d.ts)的类型检查,适用于node_modules中有两个同样的库 */ },
/*=== File Inclusion 文件包含 ===*/ "include": ["src"], "exclude": ["src/**/*.tsx","test", "stories"] }
|