tsconfig.json 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {
  2. "compilerOptions": {
  3. "target": "esnext",
  4. "module": "esnext",
  5. "strict": true,
  6. "noImplicitAny": false,
  7. "lib": ["dom", "esnext"],
  8. "jsx": "preserve",
  9. "moduleResolution": "node",
  10. "esModuleInterop": true, // ES 模块互操作,import React from 'react';react是module.exports导出的,因此需要设置该属性
  11. "forceConsistentCasingInFileNames": true, // 在文件名中强制使用一致的大小写
  12. "skipLibCheck": true, // 跳过d.ts声明文件的类型检查。
  13. "resolveJsonModule": true, //解析json模块
  14. "allowJs": true,
  15. "checkJs": true,
  16. "baseUrl": "./",
  17. /**
  18. * 当 TypeScript 编译文件时,它在输出目录中保持与输入目录中相同的目录结构。
  19. * 如果你设置了allowJs:true,就会导致输入目录的js文件,编译后又输出到了同样的目录结构,
  20. * 就会报错:无法写入文件xxx,因为它会覆盖输入文件。
  21. * 因此手动设置输出目录,让输出目录不和原本的目录一致即可
  22. */
  23. "outDir": "./dist",
  24. "paths": {
  25. "@/*": ["src/*"],
  26. "script/*": ["script/*"]
  27. }
  28. // "paths": {
  29. // "@/*": ["./src/*"] // 这样写的话,@/不会提示路径,得使用baseUrl:'./'+paths:{"@/*": ["src/*"]}这样才的话@/才会提示路径
  30. // }
  31. },
  32. // 仅仅匹配这些文件,除了src以外的文件都不会被匹配
  33. "include": [
  34. "src/**/*.ts",
  35. "src/**/*.tsx",
  36. "src/**/*.vue",
  37. "script/**/*.ts",
  38. "./.eslintrc.js",
  39. "./babel.config.js",
  40. "./postcss.config.js",
  41. "windi.config.ts"
  42. ],
  43. // https://github.com/microsoft/TypeScript/wiki/Performance
  44. "exclude": ["**/node_modules"],
  45. // ts-node的时候会读取这里的配置
  46. "ts-node": {
  47. "compilerOptions": {
  48. "module": "commonjs" // 指定生成什么模块代码。
  49. },
  50. "transpileOnly": true // 只编译,报警告或者错误一样运行
  51. }
  52. }