tsconfig.json 2.0 KB

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