如何改善模块别名tsconfig rootDirs,baseURL和路径?

时间:2020-09-23 07:12:21

标签: node.js typescript koa tsconfig

我的项目有一个tsconfig,项目结构为 MyProject/src/my-files,然后将其输出到MyProject/dist/my-files

{
  "compilerOptions": {
    "target": "ES2017",
    "module": "commonjs",
    "lib": ["es6"],
    "outDir": "dist",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "rootDirs": ["."],
    "baseUrl": ".",
    "paths": {
      "Config/*": ["src/config/*", "dist/config/*"],
      "Controllers/*": ["src/controllers/*", "dist/controllers/*"],
      "Helpers/*": ["src/helpers/*", "dist/helpers/*"],
    },
    "skipLibCheck": true,
    "types": ["node", "jest"],
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  },
  "include": ["src/**/*"]
}

有没有一种方法可以减少路径冗余

之前:paths:{ "Config/*": ["src/config/*", "dist/config/*"]...

进入:paths:{ "Config/*": ["config/*"]...

"rootDirs": ["."],更新为"rootDirs": ["src", "dist],无效,并导致解析解析别名失败

0 个答案:

没有答案