-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Try subtype reducing call expression types if type argument arity checks will fail #60036
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
Try subtype reducing call expression types if type argument arity checks will fail #60036
Conversation
…cks are all going to fail
@typescript-bot test it |
Hey @weswigham, the results of running the DT tests are ready. Everything looks the same! |
@weswigham Here are the results of running the user tests with tsc comparing Everything looks good! |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@weswigham Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
@typescript-bot pack this |
Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
We basically peek into a cheap part of overload resolution and see if we're destined to report an error on a union's list of signatures, and, if so, try subtype reducing the union and then doing the arity checks. If we can find a matching signature in the reduced union, we proceed with that, instead, and avoid the error.
Note that, per the comment in the code, right now I only do this for call expressions, and not other call-like expressions (decorators, tagged templates, jsx tags), because of where this logic needs to sit in the call resolution stack. If we like it, I can make the logic a bit more generic and insert it into all the call resolution codepaths (it's an interesting bit of logic since it needs both expression type information and signature level information - and the core
resolveCall
only operates on the later).Fixes #60006