Use type references for better error messages when relating to a union type #24776
Labels
Bug
A bug in TypeScript
Domain: Error Messages
The issue relates to error messaging
Fixed
A PR has been merged for this issue
Milestone
When relating
A<Foo>
toA<Bar> | B<Baz> | C<Kwah>
, if the check fails, it is highly likely that the user wants to see the elaboration fromA<Foo>
toA<Bar>
, rather than forA<Foo>
toB<Baz>
orA<Foo>
toC<Kwah>
.We should try to find candidates when source types are type references, and target types are unions.
As a real-world example, here's an error message where TypeScript had the chance to relate
ComponentClass<...>
toComponentClass<...> | StatelessComponent<...>
:https://news.ycombinator.com/item?id=17244638
This should also work for if two types have a well-known type alias.
Vaguely related to #6541?
The text was updated successfully, but these errors were encountered: