-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Description
Bug Report
I'm maintaining a type that infers the response type for an Elasticsearch request based on its input. After upgrading to 4.3.5 in the Kibana repo Intellisense has become terribly slow for us and one place where I see a pretty big slowdown is in these types (which all of our APIs depend on). After manually bisecting some changes between 4.2 and 4.3 I'm suspecting #43527 is the culprit.
The type is a recursive one, but not directly (ie, it calls itself via other types it creates).
From looking at the trace data that TS itself generates and profiling via pprof I see a lot of time is being spent in getVariancesWorker (via getAliasVariances) and recursiveTypeRelatedTo/structuredTypeRelatedTo.
Is there a better way to write these types that work with 4.3 and 4.4 in a reasonable manner? If not, is it possible that whatever fixed it in 4.5 is backported to 4.3? I'm not expecting is to be able to upgrade to 4.5 any time soon, we just completed a painful upgrade to 4.3.
🔎 Search Terms
recursive type, tail-recursive, union, map, performance, getVariancesWorker, getRecursionIdentity, getVariancesWorker, recursiveTypeRelatedTo, structuredTypeRelatedTo
4.2.3, 4.3.5, 4.4.4, 4.5.2
🕗 Version & Regression Information
This changed between versions 4.2.3 and 4.3.5
⏯ Playground Link
https://ela.st/faster-typescript-es-perf
If you uncomment the bottom line and re-type it you should be able to see a huge difference in responsiveness in 4.2/4.5 vs 4.3/4.4.
💻 Code
See playground link.
🙁 Actual behavior
Autocompletion takes a long time (+5s).
🙂 Expected behavior
Autocompletion should be instant.