Add extendsExact: bool property to tsconfig.json · Issue #30163 · microsoft/TypeScript (original) (raw)

Search Terms

Lerna monorepo, extends, config inheritance, disable relative path.

Suggestion

According to design choise of extends property to make paths relative - it brings some problems for monorepos with multiple packages with different configs.

I suggest to add extendsExact: bool property to tsconfig.json which will keep paths as is (without resolving relative paths)

It quite simple to implement with current codebase and allows to developers use different scenarios.

Use Cases

We cannot use base template for all packages (we have 20 packages and need to fix in every config includes and excludes sections). It quite hard to track. If we add something to base template, we should to change all tsconfigs in every package.

My real use case is quite complex. We have boilerplate repo, where defined all configs, dev packages and code conventions. I maintain this MAIN repo. All other developers fork my repo and adds their code to packages folder (in Lerna way) where use some of config from root folder for their packages. So at any time I may update my boilerplate (MAIN repo) and all other teams may easily merge my changes without affecting their code in packages folder.

Examples

We have a base configs:

// tsconfig.server.json { excludes: ["node_modules"], includes: ["src/**/*.ts", "server.globals.ts"] }

// tsconfig.client.json { excludes: ["node_modules", "tests"], includes: ["src/**/*.ts"] }

And in Lerna monorepo developers may use these tsconfig as real dumb template:

tsconfig.server.json
tsconfig.client.json
lerna.json
packages/
 - pkg1-server
     - tsconfig.json { extends: '../../tsconfig.server.json', extendsExact: true } 
 - pkg1-client
     - tsconfig.json { extends: '../../tsconfig.client.json', extendsExact: true }      
 - pkg1-client-admin
     - tsconfig.json { extends: '../../tsconfig.client.json', extendsExact: true } 
 - pkg2-node-driver
     - tsconfig.json { extends: '../../tsconfig.server.json', extendsExact: true } 
 - ... tons of other packages ...

So with such monorepo I can just change root config file, and all packages gets new config with EXACT paths for (files, includes, excludes) like they are in root config files.

Checklist

My suggestion meets these guidelines: