主要作用:
一般文件有我们ts代码的时候,它就会有这么一个文件,这个ts.json 文件是 ts的一个配置文件,
我们首先要知道这个ts 文件最终一定会转成我们的 js 文件的。
转化过程:
1.先对ts代码做一个编译,看下基本语法有没有问题
2.如果基本语法没问题,在做一个转化
3.转化之后得到我们的js文件
//编译选项
"compilerOptions": {`在这里插入代码片`
//目标代码(ts-->js(es6/6/7)
"target": "esnext",
// 目标代码需要使用的模块化方案(commonjs require/module.export),umd 会支持多种模块化
"module": "esnext",
//严格模式,严格一些严格的检查
"strict": true,
//要不要对jsx 进行怎样的处理
"jsx": "preserve",
// 按照node的方式去解析模块 import"/index.node"
"moduleResolution": "node",
// 跳过对整个库的类型检测
"skipLibCheck": true,
// export default/module.export={}能不能来混合使用
// es module 和 commonjs
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": true,
// 要不要生成映射文件(ts-->js)
"sourceMap": true,
// 文件路径在解析时,基本url
"baseUrl": ".",
// 指定具体要解析使用的类型
"types": ["webpack-env"],
// 编译时路径解析(类似于于 webpack alias)
"paths": {
"@/*": ["src/*"],
"components/*":["src/components/*"]
},
// 可以指定在项目中可以使用哪里库的类型
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": ["node_modules"]