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

Expected 0-2 type arguments, but got 1 #28053

Closed
ghost opened this issue Oct 22, 2018 · 6 comments
Closed

Expected 0-2 type arguments, but got 1 #28053

ghost opened this issue Oct 22, 2018 · 6 comments
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@ghost
Copy link

ghost commented Oct 22, 2018

TypeScript Version: 3.2.0-dev.20181020

Code

new Map<string>();

(as of #28052)

Expected behavior:

No overload expects 1 type argument, but overloads do exist that expect either 0 or 2 type arguments.

Actual behavior:

Expected 0-2 type arguments, but got 1.

Related Issues: #19220

@ghost ghost added Bug A bug in TypeScript Help Wanted You can do this Domain: Error Messages The issue relates to error messaging labels Oct 22, 2018
@fatcerberus
Copy link

To be clear, the issue is with the error message and not the error itself, correct?

@ghost
Copy link
Author

ghost commented Oct 22, 2018

Right.

@pesca
Copy link
Contributor

pesca commented Oct 27, 2018

@andy-ms As per #19220, the error should give the next lowest and highest arity. What if the arity is not between a pair? Consider:

new Map<any, any, any>();

We get Expected 0-2 type arguments, but got 3 which isn't contradictory (like the one this issue is trying to address) but still misleading.

Also the expected behavior is incorrect when the given arity does not equal 1. Example: No overload expects 3 type argument. Several error messages overlook this detail. Possible solutions:

  • Relevant morphemes are parenthesized: No overload expects 5 type argument(s)
  • Relevant words are parametrized

@ghost
Copy link
Author

ghost commented Nov 2, 2018

Relevant words are parametrized

I don't think that would work with localization -- we can't have No_overload_expects_5_type_0, "arguments" because "arguments" isn't the right word in yiddish. So we have to create two separate error codes if we want to support plurals.

As for Expected 0-2 type arguments, but got 3, I suppose that could be No overload expects 3 arguments, but an overload does exist that expects 2 arguments.

@pesca
Copy link
Contributor

pesca commented Nov 6, 2018

@andy-ms OK, I opened a PR.

@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Dec 12, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.3 milestone Dec 12, 2018
@DanielRosenwasser
Copy link
Member

Thanks @pesca!

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 Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants