-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
an emitter with 239 events breaks type check, throw ts2590 Expression produces a union type that is too complex to represent #42790
Comments
@ahejlsberg or @weswigham interested in looking at this? |
I have looked at this and have a pretty good grasp of what's up at this point. First: You "only" have 239 top-level events... but each of those events may have multiple possible payload shapes. So the handler arrow function signature's contextual type looks like So there's two things I've come up with that we can do to improve here, and I have implementations for both, I just don't know if we wanna do both, and, if so, together or separately.
|
Hello, are there any plans to handle this particular issue? I am still seeing this error on typescript 4.5.5. Or Can you please provide a workaround like a tsconfig.json settings to disable/set higher limit for the too complex type error? |
Bug Report
I wrote a framework (namely koishi) which uses a fully-typed event emitter implemented by itself. However when I create more events (totally 239), the type check just broke with an error ts2590 (Expression produces a union type that is too complex to represent). It seems that the error was thrown here:
I know 239 events is a lot, but I still cannot figure out how the 239 events became "100000 type checks".
Can you help prevent this error either by optimize type check performance or by improve my code? Thanks.
🔎 Search Terms
union type, interface, event emitter, ts2590
🕗 Version & Regression Information
I tried with v4.1.3, v4.1.5 & v4.2.1-rc. They all failed.
⏯ Playground Link
This playground will not work because it imports a dependency
@octokit/webhooks-definitions
(it's just a simple collection of github webhooks type definitions, but it is too big (over 5000 lines) to be included as I thought).Playground link with a dependency
And the dependency code can be found here: https://unpkg.com/@octokit/[email protected]/schema.d.ts
💻 Code
🙁 Actual behavior
TS2590 error: Expression produces a union type that is too complex to represent.
🙂 Expected behavior
No compiler error
The text was updated successfully, but these errors were encountered: