免费帮忙做网站,如何给网站增加外链,做邮轮上哪个网站订票好,安嶶省城乡建设网站基本了解
tsconfig.json 是 ts 支持的配置文件
大体可以分为两个部分描述#xff0c;
第一部分#xff1a;编译规则配置(compilerOptions)#xff0c;第二个部分#xff1a;哪些文件进行编译(files,include,exclude)
{compilerOptions: {},files
第一部分编译规则配置(compilerOptions)第二个部分哪些文件进行编译(files,include,exclude)
{compilerOptions: {},files: [], include: [],exclude: []
}# ts配置相关命令
tsc # 默认使用最近配置文件
tsc --all # 所有编译选项
tsc --all | grep keyofStringsOnly # 某一个编译选项
tsc --init # 可以生产默认的配置文件demo:常见配置
{// files: 适用于比较小型的项目规定几个特定的文件// 将compilerOption的编译规则应用于index.ts下files: [index.ts], // include: 所有src目录和test目录下的文件都会被编译include:[src/**/*, test/**/*] // exclude: 不需要被编译的文件目录exclude: [ node_modules,dist,**/*.test.ts], compilerOptions: { // 用于抑制隐式 any 索引错误的报告。在ts5.5版本是废弃的属性 suppressImplicitAnyIndexErrors: true,// 忽略废弃警告ignoreDeprecations: 5.0, // 跳过对所有声明文件.d.ts 文件的类型检查// 跳过类型检查可能会隐藏潜在的类型不一致问题建议仅在明确的情况下使用skipLibCheck: true,// types: 告诉 ts 编译器要引入哪些第三方库或模块的类型声明// 当 TypeScript 编译器遇到使用 React 或 Lodash 的代码时它会根据指定的类型声明文件进行类型检查和推断以确保你的代码与这些库的 API 相符合。types: [react, lodash],// 没有设置baseUrl: import { example } from ./src/hello/world// 设置了baseUrl: import { example } from hello/worldbaseUrl: .,// paths必须和baseUrl联合使用// 设置paths后:import from /components/Button import from 相当于 src/components/Buttonpaths: {/*: [src/*]},// lib: 引入ES功能库如想在项目中用js中SetMappromise等需引入es2015lib: [es6, dom], // 编译成哪个版本的jses3,es5,es6...target: es5, // 哪个模块规范: cjs,amd,umd,esmmodule: commonjs, // 选择模块解析策略 比如 在node_modules中查找路径// node: Node.js’ CommonJS implementation 》 ts 社区最常用的推荐大多数项目// node16 or nodenext: Node.js’ ECMAScript Module Support from TypeScript 4.7 onwards// classic: used in TypeScript before the release of 1.6. moduleResolution: node, experimentalDecorators: true, // 启用实验性的ES装饰器// 允许从没有设置默认导出的模块中默认导入// false: 必须 import * as React from react // true: 可以 import React from reactallowSyntheticDefaultImports: true, // sourceMap 把 ts 文件编译成 js 文件的时候同时生成对应的 map 文件sourceMap: true, strict: true, // 启用所有严格类型检查选项// noImplicitAny: 不允许用any如果初学ts建议项目部太复杂的情况下可以借此来进行限制前置自己培养对ts的理解 (实际情况不是)noImplicitAny: true, // 在表达式和声明上有隐含的 any类型时报错alwaysStrict: true, // 以严格模式检查模块并在每个文件里加入 use strictdeclaration: true, // 生成相应的.d.ts文件// 删除编译后的所有的注释removeComments: true, noImplicitReturns: true, // 不是函数的所有返回路径都有返回值时报错importHelpers: true, // 从 tslib 导入辅助工具函数// typeRoots: 指定类型声明文件的根目录路径typeRoots: [./node_modules/types/, // 这是个目录./types // 这是个目录],outDir: ./dist,rootDir: ./src,keyofStringsOnly: false, },}