文件夹内的特定 tsconfig.json 规则

Gus*_*pes 13 typescript tsconfig

如何config.json在我的 Typescript 项目中使用内部?

为清楚起见:

我有一个根/config.json如下:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2017",
        "inlineSourceMap": true,
        "outDir": "./app/",
        "lib": [
            "es6"
        ],
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "moduleResolution": "node",
        "baseUrl": "./",
        "noImplicitAny": true,
        "skipLibCheck": true, 
        "paths": {
            "*": [
                "types/*"
            ]
        }
    },
    "include": [
        "./src/**/*.ts"
    ]
}
Run Code Online (Sandbox Code Playgroud)

我想拥有/innerFolder/config.json以下内容:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "noImplicitReturns": true,
    "noUnusedParameters": true,
    "noUnusedLocals": true,
    "strictNullChecks": true,
  }
}
Run Code Online (Sandbox Code Playgroud)

我这样做是因为我想对团队的代码进行重构,但它很大,我不想一次更改我的所有文件。

我想逐个文件夹执行此操作,并使用更改“锁定”文件夹。

根据文档,编译器会查找 parent tsconfig.json,但不会查找特定的tsconfig.json.

有没有办法做到这一点?

thi*_*ign 5

TypeScript 2.1添加了配置继承,现在应该可以按照您使用的方式工作。


Gus*_*pes 1

一旦我只需要严格检查的规则,我就可以使用tslint.

extendsfromtslint正是我需要的,它会下降,覆盖内部目录中的规则。