Skip to content

Add extendsExact: bool property to tsconfig.json #30163

@nodkz

Description

@nodkz

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:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions