TS的tsconfig.json配置
1.开发环境 vue+typescripts+element+echarts
2.电脑系统 windows10 专业版
3.在开发的过程中,咱们常常会应用到typescripts进行开发我的项目,上面我来说一下对于ts中tsconfig.json文件的配置:
{ "compilerOptions": { // "incremental": true, // 增置编译
// "tsBuildlnfoFile": "./buildFile", // 增置编译文件的存储地位
// "diagnostics": true, // 打印诊断倍息
// "target": "es5", // 目标语言的版本
// "module": "commonjs", // 生成代码的模块规范
// "outFile": "./app-js", // 将多个相互依赖的文件生成一个文件,能够用在AMD模块中
// "lib": [], // TS 须要援用的库,即申明文件,es5 默认"dom", "es5", "scripthost"
// "allowJs": true, // 容许编译:IS 文件(js、jsx)
// "checkJs": true, // 容许在JS文件中报错,通常与allowJS _起应用
// "outDir": "./dist", // 指定输入目录
// "rootDir": "./", // 指定输出文件目录(用于输入)
// "declaration": true, // 生成申明文件
// "declarationDir": "./d", // 申明文件的门路
// "emitDeclarationOnly": true, // 只生成申明文件
// "sourceMap": true, // 生成指标文件的 sourceMap
// "inlineSourceMap": true, // 生成指标文件的 inline sourceMap
// "declarationMap": true, // 生成申明文件的 sourceMap
// "typeRoots":[], // 申明文件目录,默认node_modules/@types
// "types":[], // 申明文件包
// "removeComments":true, // 删除正文
// "noEmit": true, // 不输入文件
// "noEmitOnError": true, // 产生谬误时不输入文件
// "noEmitHelpers": true, // 不生成helper 函数,须要额定装置ts-helpers
// "importHelpers": true, // 通过tslib 引入 helper 函数,文件必须是模块
// unoEmitOnErrorM: true, // 产生谬误时不输入文件
// "noEmitHelpers": true, // 不生成 helper 函数,需额定装置 ts-helpers
// "importHelpers": true, // 通过tslib引入helper函数,文件必须是模块
// "downlevellteration" : true, // 降级遍历器的实现(es3/5)
// "strict": true, // 开启所有严格的类型查看
// "alwaysStrict": false, // 在代码中注入"use strict";
// "noImplicitAny": false, // 不容许隐式的any类型
// "strictNullChecksilj false, // 不容许把null、undefined赋值给其余类型变置
// "strictFunctionTypes": false, // 不容许函数参数双向协变
// "strictPropertyInitialization": false, // 类的实例属性必须初始化
// strictBindCallApply: false, // 严格的 bind/call/apply 检査
// "noImplicitThis": false, // 不容许this有隐式的any类型
// "noUnusedLocals": true, // 检査只申明,未应用的部分变置
// "nollnusedParameters": true, // 查看未应用的函数参数
// "noFallthroughCasesInSwitch": true, // 避免switch语句贯通
// "noImplicitReturns": true, // 每个分支都要有返回值
// "esModulelnterop": true, // 容许export = 导出,由import from导入
// "allowUrndGlobalAccess": true, // 容许在模块中拜访UMD全局变置
// "moduleResolution": "node", // 模块解析策略
// "baseUrl": "./", // 解析非绝对模块的基地址
// "paths": {
// "jquery": ["node-modules/jquery/dist/jquery.slim.min.js"]
// }
// "rootDirs": ["src", "out"], // 将多个目录放在一个虚拟目录下,用于运行时
// "listEmittedFiles": true, // 打印输出的文件
// "listFiles": true, // 打印编译的文件(包含援用的申明文件)
}, // "include": [ // 指定一个匹配列表(属于主动指定该门路下的所有ts相干文件)
// "src/**/*.ts",
// "src/**/*.tsx",
// "src/**/*.vue",
// "tests/**/*.ts",
// "tests/**/*.tsx"
// ],
// "exclude": [ // 指定一个排除列表(include的反向操作)
// "node_modules"
// ],
// "files": [ // 指定哪些文件应用该配置(属于手动一个个指定文件)
// "demo.ts"
// ]
}
4.如果在赶我的项目的时候,如果在终端还是有正告,临时无奈解决的话,无奈打包的话,能够批改配置:
"strict": false,//// 敞开所有严格的类型查看
5.配置完4之后,你就会发现终端不会报错了,这样就能够进行打包了。
6.本期的教程到了这里就完结啦,是不是很简略,让咱们一起致力走向巅峰,加油!
发表回复