Improve error message for incompatible signatures in union type from typed/untyped function call #27422
Open
4 tasks done
Labels
Domain: Error Messages
The issue relates to error messaging
Experience Enhancement
Noncontroversial enhancements
Suggestion
An idea for TypeScript
Milestone
Search Terms
untyped function call error message union type incompatible signature
Example
This code errors as follows:
which feels strange given that both of the following are fine:
If an evaluation contexts accepts values of type
A
and values of typeB
, then it should accepts values of typeA | B
. I think what is going on is that the call signature fromT & Function
is untyped, which is incompatible with the typed signature of() => string
.I don't think this is very obvious to a user, and they end up seeing an application that works for both branches of a union, but not their composition.
Suggestion
I think making the example work is out of scope. My suggestion is to improve the error message, something like:
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: