tsconfig.json 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. "baseUrl": "./",
  16. /**
  17. * 当 TypeScript 编译文件时,它在输出目录中保持与输入目录中相同的目录结构。
  18. * 如果你设置了allowJs:true,就会导致输入目录的js文件,编译后又输出到了同样的目录结构,
  19. * 就会报错:无法写入文件xxx,因为它会覆盖输入文件。
  20. * 因此手动设置输出目录,让输出目录不和原本的目录一致即可
  21. */
  22. "outDir": "./dist",
  23. "paths": {
  24. "@/*": ["src/*"],
  25. "script/*": ["script/*"]
  26. }
  27. // "paths": {
  28. // "@/*": ["./src/*"] // 这样写的话,@/不会提示路径,得使用baseUrl:'./'+paths:{"@/*": ["src/*"]}这样才的话@/才会提示路径
  29. // }
  30. },
  31. // 仅仅匹配这些文件,除了src以外的文件都不会被匹配
  32. "include": [
  33. "src/**/*.ts",
  34. "src/**/*.tsx",
  35. "src/**/*.vue",
  36. "script/**/*.ts",
  37. "./.eslintrc.js",
  38. "./babel.config.js",
  39. "./postcss.config.js",
  40. "windi.config.ts"
  41. ],
  42. // https://github.com/microsoft/TypeScript/wiki/Performance
  43. "exclude": ["**/node_modules"],
  44. // ts-node的时候会读取这里的配置
  45. "ts-node": {
  46. "compilerOptions": {
  47. "module": "commonjs" // 指定生成什么模块代码。
  48. },
  49. "transpileOnly": true // 只编译,报警告或者错误一样运行
  50. }
  51. }