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

Most upvoted comments

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 extends lookups 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/commons has an exports field 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?

I assume this is a legit regression bug.

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 exports map.