-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TypeScript 4.7.4: Exponential behavior in strict type checking #49845
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
Comments
same problem |
@RyanCavanaugh happy to provide more info, but I was hoping I could get some advice on how to collect it. |
Sorry, digging up my notes. Here's a doc I've been working on; let me know if it helps Diagnosing Crashes for Report PurposesRun
|
Great, thanks, that should hopefully get me going. Since this isn't a crash but rather a infinite (or extremely long) loop, will start printing stuff and see where it's getting stuck. |
Thanks for the help. FWIW I wasn't able to get |
I'm back :) The Angular folks have distilled a reproducer into something that happens with plain tsc. You can see the full comment here: angular/angular#46792 (comment) Problematic sample reproduced here for completeness, courtesy of @JoostK: declare const arr: string[];
(((((((((((((((((!arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length) && !arr.length); This takes an unnecessarily long time, probably some sort of exponential situation going on. This happens with TS 4.7 and not TS 4.6.
Let me know what, if any, additional info is necessary. |
I suspect this is caused by #42835. Looking at the change, it introduces a call to |
I opened #49881 with a fix. |
That |
Generated code may look like this. |
In reality, they're different arrays, and the expression isn't nested but rather a simple |
When upgrading from TypeScript 4.6.4 to 4.7.4 in a large Angular application, I'm seeing an infinite loop when trying to compile. Adding
--trace-sigint
to the node invocation, I see some traces like:The trace is generally different each time, but usually in
checkExpressionWorker
somewhere. Unfortunately this is hardcoded to 10 calls in the trace. Sometimes the traces just have a lot ofgetTypeAtFlowNode
without much additional context.This is a large, proprietary application, so unfortunately I can't provide a repro. The project has a number of the "advanced" type checking bits enabled (and one disabled):
I'm happy to apply any local patches to improve the ability to pinpoint the bit of code it's unhappy with, but I'm entirely unfamiliar with the codebase, so some hints could be useful. Also let me know if any additional info would be useful.
Node version v14.19.3, in case it matters.
The text was updated successfully, but these errors were encountered: