Skip to content
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

Use type references for better error messages when relating to a union type #24776

Closed
DanielRosenwasser opened this issue Jun 7, 2018 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

When relating A<Foo> to A<Bar> | B<Baz> | C<Kwah>, if the check fails, it is highly likely that the user wants to see the elaboration from A<Foo> to A<Bar>, rather than for A<Foo> to B<Baz> or A<Foo> to C<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<...> to ComponentClass<...> | StatelessComponent<...>:

https://news.ycombinator.com/item?id=17244638

image

This should also work for if two types have a well-known type alias.

Vaguely related to #6541?

@DanielRosenwasser DanielRosenwasser changed the title Use type references for better error messages when relating a type to a union type Use type references for better error messages when relating to a union type Jun 7, 2018
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging labels Jun 7, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.0 milestone Jun 8, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants