dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.
MIT License
1.8k stars 100 forks source link

Add support for extends as array of strings. #245

Closed DanielSidhion closed 1 year ago

DanielSidhion commented 1 year ago

Fixes #244.

TypeScript 5.0 added support for defining "extends" as an array of strings. This commit adds support for this use case.

It's important to note that even with this change, "baseUrl" and "paths" are still always being completely overwritten if a later tsconfig redefines any of those values. This might be confusing because a tsconfig may define "baseUrl=value1" and its own set of "paths" based on that baseUrl, but if a later tsconfig defines its own "baseUrl=value2", the overall config ends up becoming "baseUrl=value2" with the "paths" from the first config.

This behaviour hasn't changed even when "extends" is an array of strings, so this commit maintains this behaviour.

DanielSidhion commented 1 year ago

@jonaskello pinging you because you seem to handle merging PRs in this repo. What's your review and release process like? This PR will help me migrate a bunch of projects I have to TypeScript 5.0 (as long as tsconfig-paths-webpack-plugin also works well with this change, but I'll take a look at that one once this PR is done).

WoodyWoodsta commented 1 year ago

I'm blocked by this as well (via eslint-plugin-import). TS 5 started its beta 2 months ago :)

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 82.60% and project coverage change: +0.27 :tada:

Comparison is base (910a138) 68.16% compared to head (540a1c1) 68.43%.

:exclamation: Current head 540a1c1 differs from pull request most recent head 62c1b80. Consider uploading reports for the commit 62c1b80 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #245 +/- ## ========================================== + Coverage 68.16% 68.43% +0.27% ========================================== Files 9 9 Lines 311 320 +9 Branches 96 99 +3 ========================================== + Hits 212 219 +7 Misses 93 93 - Partials 6 8 +2 ``` | [Impacted Files](https://codecov.io/gh/dividab/tsconfig-paths/pull/245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dividab) | Coverage Δ | | |---|---|---| | [src/tsconfig-loader.ts](https://codecov.io/gh/dividab/tsconfig-paths/pull/245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dividab#diff-c3JjL3RzY29uZmlnLWxvYWRlci50cw==) | `83.56% <82.60%> (-0.82%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dividab). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dividab)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

ljharb commented 1 year ago

It'd be great if this could be backported to v3 as well, which has 3-4 times the downloads of v4.

KozelAnatoliy commented 1 year ago

Would be great to merge this one because it is blocking projects that uses esbuild to migrate to typescript 5

jonaskello commented 1 year ago

@DanielSidhion If I understand correctly this change is not breaking and could be released in a minor version?

DanielSidhion commented 1 year ago

@DanielSidhion If I understand correctly this change is not breaking and could be released in a minor version?

That's correct, I kept the same behaviour as before for any extends that's just a string, and TS 5.0 doesn't introduce any breaking changes to how it handles extends that are strings AFAIK.

jonaskello commented 1 year ago

Released in 4.2.0

ljharb commented 1 year ago

@jonaskello any plans to backport this to v3?