Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'deep' extension #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dirkgroenen
Copy link

Typescript has support for deep config extensions, but it seems like tsconfig-paths isn't handling this too well and stops after the first 'extend'.

This rewrite makes sure it 'keeps on extending' until no 'extends' property is found.

@codecov
Copy link

codecov bot commented Mar 19, 2020

Codecov Report

Merging #112 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #112   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           4       4           
  Lines         129     129           
  Branches       52      52           
======================================
  Misses        129     129           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32338c6...61bab21. Read the comment docs.

@dirkgroenen
Copy link
Author

Hi @jonaskello, any change of checking this out and getting it merged? :)

@effervescentia
Copy link

effervescentia commented Mar 10, 2023

hey @jonaskello I'm running into the same problem trying to use a tool many steps removed from your own library (dependency-cruiser)

My company has a fairly complex typescript configuration setup which we have extracted to a config that is extended from multiple levels deep, as a result the paths configuration that is inherited is unfortunately ignored by your library.
Perhaps you could update your tsconfig resolution to just use what is provided out-of-the-box by typescript itself to avoid needing to concern yourself with the details of how config extension actually works

https://typestrong.org/ts-node/api/interfaces/TSCommon.html#readConfigFile
https://typestrong.org/ts-node/api/interfaces/TSCommon.html#parseJsonConfigFileContent

you should be able to use something like the following

import typescript from 'typescript';

const rawConfig = typescript.readConfigFile('tsconfig.json', typescript.sys.readFile);

const fullConfig = typescript.parseJsonConfigFileContent(
  rawConfig.config,
  typescript.sys,
  'path/to/repo',
  {},
  'tsconfig.json'
);

fullConfig.options; // tsconfig compiler options (with all inherited values)

ironically I originally saw this while exploring the codebase of dependency-cruiser trying to get to the bottom of this issue
https://github.com/sverweij/dependency-cruiser/blob/master/src/config-utl/extract-ts-config.js#L52

I'm also happy to make a PR with the above change if you like the solution but don't have the time to implement it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants