TypeScript: TS 5 Regression. tsconfig extends stop resolving references to node_modules
Bug Report
๐ Search Terms
TS 5, tsconfig, extends, node modules
๐ Version & Regression Information
5.0.2
In latest stable build, 4.9.5, tsconfig extends resolve correctly references to libraries on node modules. However, after trying out 5.0.2 it has stop working
- This changed between versions 4.9.5 and 5.0.2
 
โฏ Playground Link
No Playground, I quickly check and there is no support for tsconfig, package.json,โฆ
๐ป Code
No code, itโs just configuration. Having a package.json declaring
 "devDependencies": {
    "@mylibrary/commons": "1.0.0",
    "typescript": "5.0.2"
  }
and a tsconfig with:
"extends": "@mylibrary/commons/configs/tsconfig.backend.json",
๐ Actual behavior
The command tsc --build finish with error:
tsconfig.json:2:14 - error TS6053: File '@mylibrary/commons/configs/tsconfig.backend.json' not found.
2   "extends": "@mylibrary/commons/configs/tsconfig.backend.json",
๐ Expected behavior
The command tsc --build finish correctly.
About this issue
- Original URL
 - State: closed
 - Created a year ago
 - Reactions: 2
 - Comments: 28 (13 by maintainers)
 
Commits related to this issue
- fix: add tsconfig to exports map TypeScript used to be able to resolve the extends field in `tsconfig.json` using the node require algorithm. Recent versions of TypeScript have a regression that mea... — committed to ipfs/aegir by achingbrain a year ago
 - fix: add tsconfig to exports map (#1278) TypeScript used to be able to resolve the extends field in `tsconfig.json` using the node require algorithm. Recent versions of TypeScript have a regressi... — committed to ipfs/aegir by achingbrain a year ago
 
We decided this was intentional, minus the wildcard issue, which Iโll put up a fix for shortly. If a package wants to make its tsconfig.json available for extending, and has an
"exports"in its package.json, it needs to make sure the tsconfig is reachable via those"exports".I think this is a bug, AFAIK
extendslookups should always be done as CJS lookups. Probably weโll have to revisit that logic at some pointโฆThe original issue here is most definitely fixed. If you are having a problem in a recent release, please file a new issue.
If you are using ts-node, maybe you are seeing https://github.com/microsoft/TypeScript/issues/56492.
Still experiencing the same issue. Was this fully resolved?
See #53557. @DanielRosenwasser
โIfโ was a little too loose; we definitely wanted this to be backported to 5.0, per design meeting discussion. We just have to merge the cherry-pick before release.
This is most likely because
@mylibrary/commonshas anexportsfield on package,json without exporting the file.If we take it, 5.0.3.
The fix is already available in nightly. I just had the bot open a PR to pull the fix back into 5.0, since I think we wanted that.
If itโs not working in nightly, then thatโs a problem.
It looks like the current behavior was accepted as being intentional in https://github.com/microsoft/TypeScript/issues/48665, and implemented in https://github.com/microsoft/TypeScript/pull/50955. Are we wanting to reconsider that decision, or did we just forget to mark it as a breaking change?
Yes, note the label on the issue.
@mike-lischke This issue is about tsconfigโs extends clause. Your issue is unrelated; please file a separate issue.
The reason I said is because I hit this problem when upgrading to 5.0 and I fixed it by adding an entry to the
exportsmap.