Feature Request: Allow for special tokens to be used in paths in tsconfig.json
#45050
Closed
5 tasks done
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
Add special tokens that can be used for paths in
tsconfig.json
, similar to Jest usage of the<rootDir>
tag.π Search Terms
tsconfig, extends, node, resolution, configuration
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Add special tokens that can be used for paths in
tsconfig.json
, similar to Jest usage of the<rootDir>
tag. This would be done to allow for completeextends
functionality when extending a dependencyπ Motivating Example
TypeScript
tsconfig.json
files have the ability to extend from othertsconfig.json
files through the use of Node-resolved packages. This has the benefit of making extending from base tsconfig files contained in a dependency quite easy and clean. However, all path-based options withintsconfig.json
(likeinclude
,exclude
, etc.) are pathed relative to the dir of thetsconfig.json
(see docs: https://www.typescriptlang.org/tsconfig#include). This is impossible because using Node resolution for theextends
field returns the real path of the tsconfig, which in some package managers (pnpm, Yarn) may not be directly under the node_modules folder. This makes it practically impossible to include path-based options in a base tsconfig since they will always need to be re-defined in the extending config to re-root the paths.π» Use Cases
The only current workaround is to use relative pathing when using the
extends
field, since this maintains the resolution structure and allows for base tsconfig files to specify paths that are resolved up through the node_modules folder, ex:tsconfig.json:
my-package/tsconfig-base.json:
If special tokens are implemented, this allows for pathing into different dirs that would otherwise be inaccessible to the base tsconfig, ex:
tsconfig.json:
my-package/tsconfig-base.json:
<rootDir>
however is just an example, and other (better) options likely exist. The general idea is to allow for referencing the top-level tsconfig file when extending a base tsconfig file.The text was updated successfully, but these errors were encountered: