Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specific tsconfig.json rules inside folder

How can I use an inner config.json in my Typescript project?

For clarity:

I have a root /config.json as following:

{
    "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"
    ]
}

I want to have a /innerFolder/config.json with the following:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "noImplicitReturns": true,
    "noUnusedParameters": true,
    "noUnusedLocals": true,
    "strictNullChecks": true,
  }
}

I'm doing that because I want to make a refactor on the team's code, but it's big and I don't want to change the all my files at once.

I want to do it folder-by-folder and "lock" the folder with the changes.

According to the documentation, the compiler looks up to a parent tsconfig.json, but not down for specific tsconfig.json.

Is there a way to accomplish that?

like image 582
Gustavo Lopes Avatar asked Oct 08 '18 20:10

Gustavo Lopes


1 Answers

TypeScript 2.1 added configuration inheritance and this should now work the way you're using it.

like image 105
thisismydesign Avatar answered Oct 21 '22 11:10

thisismydesign