-
Notifications
You must be signed in to change notification settings - Fork 309
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
[Bug]: ESM with TypeScript >= 5.0 hangs forever #2138
Comments
I've stumbled into this as well. Maybe my findings can help to find the underlying issue: Part of the problem is related to Here are my findings when debugging via (1) see: it's the same error message that @dgp1130 observed (2) going up the call stack I could very well follow a single (3) so I tried to find out where that faulty import clause comes from. Further up in the call stack I've discovered code that ran several I've opened that file and searched for (6) looking up Unfortunately that's all I can say for now (and I don't have the time to continue investigations). It could be that |
@NicBright , you're right regarding TS 5.0 breaking changes. i looked into the source code of ts@5 compiler API and see the following
Pay attention that the But in
When i manually removed second |
We're experiencing the same issue - thank you for the investigations @dgp1130, @NicBright, and @platov . I'd done the same change isolation as @dgp1130 and @NicBright, then found this issue. This issue has been blocking us upgrading to TS 5 in our repo for a few months, I hadn't had the time to isolate it until now. |
Fixes jest hang. It is described by thymikee/jest-preset-angular#2138
This issue is becoming increasingly urgent. It blocks us from upgrading to Angular 17 which requires TS >= 5.2. Any help would be welcome! |
@NicBright , I used "patch-package" npm lib to make the patch that applies automatically during |
I bet the team would take a PR... |
I'm assuming that any change to support TS5 would also have to maintain backwards compatibility with TS <5, right? I haven't looked into the code yet, but in theory If the code has any context of which TS version it's using, it could be a quick fix. With @platov's explanation above, I'd be happy to tackle it if someone could point me in the right direction. Also @platov if you could share the patch you are using with |
@joeskeen - I'm quite sure that's correct - it would have to work with TS 4.x in addition to TS 5 to be an acceptable fix. I haven't looked into this very much (besides a bunch of debugging/isolating the problem), but I do see: which looks like a way to make TS calls compatible across versions. |
Patch example for jest-preset-angular+13.1.1. Put this file in |
@ahnpnl - could you please comment on this issue? It's blocking typescript and angular upgrades for any project using jest-preset-angular, and you and/or @thymikee have been conspicuously silent on it for six months, whereas you have been extremely generous, responsive, and helpful in the past. Even if you stated "we do not intend to fix this" or "I no longer have time to donate to this project" or "I don't see a good way to fix this without breaking compatibility", that would be helpful to know for users of this project. |
One possible thing is because we relies on kulshekhar/ts-jest#4226 |
Thank you for the reply @ahnpnl . I am not familiar with all the layers in jest-preset-angular and ts-jest, but I believe this issue is not the same, though the symptoms are the same; I believe the problem here is described accurately by @platov as a breaking change in the TS 5 API. This breaking change could certainly affect both projects, but the issues look different to me. I have not tested @platov 's patch, but I will later today. |
This update appears to fix thymikee#2138. It builds with TS 5, and all tests and example tests pass.
This update appears to fix thymikee#2138. It builds with TS 5, and all tests and example tests pass. fixes: [Bug]: ESM with TypeScript >= 5.0 hangs forever thymikee#2138
* fix(ts5): Update build dependencies and types for TS 5 This update appears to fix #2138. It builds with TS 5, and all tests and example tests pass. fixes: [Bug]: ESM with TypeScript >= 5.0 hangs forever #2138 * chore(deps): Add Husky dev dependency Husky is required by the postinstall script, but was previously missing. * chore(upgrade ng): Upgrade to ng17 latest Tests pass, and example tests pass. resolves: [Feature]: Angular 17 support #2196 * chore(dedupe): yarn dedupe * fix(eslint): Disable eslint warnings due to use of "any" * chore(deps): Change dev dependency for TS to match @angular/compiler restrictions
Version
13.1.1 (current latest)
Steps to reproduce
Clone https://github.com/dgp1130/ng-large/tree/jest-preset-angular-esm-bug and run:
There's nothing particularly special about this repo. It's basically a brand new
ng new
app on latest Angular where I have attempted to set upjest-preset-angular
using ESM.Expected behavior
Test should pass as there is only one no-op component in the repository.
Actual behavior
Jest prints:
And then hangs there forever, never making any meaningful progress.
Additional context
I'm using the current latest Angular, Jest, Node, and
jest-preset-angular
. Bisecting the versions a bit, I discovered that TypeScript 5.0 introduced the error. TS 4.9.4 does not reproduce, while everything greater than 5.0 (up through 5.1.4, the current latest) fails.While Jest hangs without an error message, if you open a debugger with
--expose-internals
(npm run test:debug
in that repo), I was able to find the failing assertion which includes the error:I'm trying to use native ESM here, so I would think TypeScript should emit any imports as effectively a no-op and let Node handle the rest, so I'm not sure why TypeScript is failing to emit the import.
Environment
The text was updated successfully, but these errors were encountered: