Skip to content

Errors on non-callable unions should be more specific #29013

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

Open
weswigham opened this issue Dec 13, 2018 · 0 comments
Open

Errors on non-callable unions should be more specific #29013

weswigham opened this issue Dec 13, 2018 · 0 comments
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Milestone

Comments

@weswigham
Copy link
Member

While working on #29011 I realized that the error we produce for unions of things which look callable but for which we cannot synthesize a signature for are lackluster. We report an error like:

Cannot use 'new' with an expression whose type lacks a call or construct signature.

when we could do better and say something like

Cannot use 'new' with an expression whose type lacks a call or construct signature. All members of union type {0} have call or construct signatures, but none are similar enough to resolve a call in a typesafe way.

which would make it far more clear what's going on in these scenarios.

Once #29011 is merged, the conditions can be even more specific, such as

Cannot use 'new' with an expression whose type lacks a call or construct signature. All members of union type {0} have call or construct signatures, but more than one has overloads, which prevents this call from being resolved in a typesafe way.

and

Cannot use 'new' with an expression whose type lacks a call or construct signature. All members of union type {0} have call or construct signatures, but more than one has type parameters, which prevents this call from being resolved in a typesafe way.
@weswigham weswigham added Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements labels Dec 13, 2018
@RyanCavanaugh RyanCavanaugh added the Suggestion An idea for TypeScript label Mar 7, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants