-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Fix error message when type argument arity is wrong #28366
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bbe1fac
Fix error message when type argument arity is wrong
pesca 5d9c0f3
Merge branch 'master' into fix-issue/28053
pesca 1720a73
Parenthesize 's' in plurals
pesca 12b2d85
Merge branch 'master' into fix-issue/28053
pesca 0751d79
Update baseline
pesca c12f9fc
Merge branch 'master' into fix-issue/28053
pesca ed3e1bf
Update baseline
pesca 097ac42
Use old error message
pesca 688eabc
Revert parantheses
pesca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/baselines/reference/functionTypeArgumentArityErrors.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(4,4): error TS2743: No overload expects 2 type arguments, but overloads do exist that expect either 1 or 3 type arguments. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(5,4): error TS2558: Expected 4 type arguments, but got 5. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(10,4): error TS2743: No overload expects 2 type arguments, but overloads do exist that expect either 1 or 3 type arguments. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(11,4): error TS2558: Expected 3 type arguments, but got 4. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(16,4): error TS2558: Expected 0 type arguments, but got 1. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(20,4): error TS2558: Expected 2-3 type arguments, but got 1. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(21,4): error TS2558: Expected 2-3 type arguments, but got 4. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(25,4): error TS2558: Expected 2 type arguments, but got 1. | ||
| tests/cases/compiler/functionTypeArgumentArityErrors.ts(26,4): error TS2558: Expected 2 type arguments, but got 3. | ||
|
|
||
|
|
||
| ==== tests/cases/compiler/functionTypeArgumentArityErrors.ts (9 errors) ==== | ||
| // Overloaded functions with default type arguments | ||
| declare function f1<A = any>(): void; | ||
| declare function f1<A, B, C, D = any>(): void; | ||
| f1<number, number>(); | ||
| ~~~~~~~~~~~~~~ | ||
| !!! error TS2743: No overload expects 2 type arguments, but overloads do exist that expect either 1 or 3 type arguments. | ||
| f1<number, number, number, number, number>(); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2558: Expected 4 type arguments, but got 5. | ||
|
|
||
| // Overloaded functions with no default type arguments | ||
| declare function f2<A>(): void; | ||
| declare function f2<A, B, C>(): void; | ||
| f2<number, number>(); | ||
| ~~~~~~~~~~~~~~ | ||
| !!! error TS2743: No overload expects 2 type arguments, but overloads do exist that expect either 1 or 3 type arguments. | ||
| f2<number, number, number, number>(); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2558: Expected 3 type arguments, but got 4. | ||
|
|
||
| // Overloaded non-generic functions | ||
| declare function f3(): void; | ||
| declare function f3(a): void; | ||
| f3<number>(); | ||
| ~~~~~~ | ||
| !!! error TS2558: Expected 0 type arguments, but got 1. | ||
|
|
||
| // Generic function with default type parameters | ||
| declare function f4<A, B, C = any>(): void; | ||
| f4<number>(); | ||
| ~~~~~~ | ||
| !!! error TS2558: Expected 2-3 type arguments, but got 1. | ||
| f4<number, number, number, number>(); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2558: Expected 2-3 type arguments, but got 4. | ||
|
|
||
| // Generic function with no default type arguments | ||
| declare function f5<A, B>(): void; | ||
| f5<number>(); | ||
| ~~~~~~ | ||
| !!! error TS2558: Expected 2 type arguments, but got 1. | ||
| f5<number, number, number>(); | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2558: Expected 2 type arguments, but got 3. | ||
|
|
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/functionTypeArgumentArityErrors.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| //// [functionTypeArgumentArityErrors.ts] | ||
| // Overloaded functions with default type arguments | ||
| declare function f1<A = any>(): void; | ||
| declare function f1<A, B, C, D = any>(): void; | ||
| f1<number, number>(); | ||
| f1<number, number, number, number, number>(); | ||
|
|
||
| // Overloaded functions with no default type arguments | ||
| declare function f2<A>(): void; | ||
| declare function f2<A, B, C>(): void; | ||
| f2<number, number>(); | ||
| f2<number, number, number, number>(); | ||
|
|
||
| // Overloaded non-generic functions | ||
| declare function f3(): void; | ||
| declare function f3(a): void; | ||
| f3<number>(); | ||
|
|
||
| // Generic function with default type parameters | ||
| declare function f4<A, B, C = any>(): void; | ||
| f4<number>(); | ||
| f4<number, number, number, number>(); | ||
|
|
||
| // Generic function with no default type arguments | ||
| declare function f5<A, B>(): void; | ||
| f5<number>(); | ||
| f5<number, number, number>(); | ||
|
|
||
|
|
||
| //// [functionTypeArgumentArityErrors.js] | ||
| f1(); | ||
| f1(); | ||
| f2(); | ||
| f2(); | ||
| f3(); | ||
| f4(); | ||
| f4(); | ||
| f5(); | ||
| f5(); |
72 changes: 72 additions & 0 deletions
72
tests/baselines/reference/functionTypeArgumentArityErrors.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| === tests/cases/compiler/functionTypeArgumentArityErrors.ts === | ||
| // Overloaded functions with default type arguments | ||
| declare function f1<A = any>(): void; | ||
| >f1 : Symbol(f1, Decl(functionTypeArgumentArityErrors.ts, 0, 0), Decl(functionTypeArgumentArityErrors.ts, 1, 37)) | ||
| >A : Symbol(A, Decl(functionTypeArgumentArityErrors.ts, 1, 20)) | ||
|
|
||
| declare function f1<A, B, C, D = any>(): void; | ||
| >f1 : Symbol(f1, Decl(functionTypeArgumentArityErrors.ts, 0, 0), Decl(functionTypeArgumentArityErrors.ts, 1, 37)) | ||
| >A : Symbol(A, Decl(functionTypeArgumentArityErrors.ts, 2, 20)) | ||
| >B : Symbol(B, Decl(functionTypeArgumentArityErrors.ts, 2, 22)) | ||
| >C : Symbol(C, Decl(functionTypeArgumentArityErrors.ts, 2, 25)) | ||
| >D : Symbol(D, Decl(functionTypeArgumentArityErrors.ts, 2, 28)) | ||
|
|
||
| f1<number, number>(); | ||
| >f1 : Symbol(f1, Decl(functionTypeArgumentArityErrors.ts, 0, 0), Decl(functionTypeArgumentArityErrors.ts, 1, 37)) | ||
|
|
||
| f1<number, number, number, number, number>(); | ||
| >f1 : Symbol(f1, Decl(functionTypeArgumentArityErrors.ts, 0, 0), Decl(functionTypeArgumentArityErrors.ts, 1, 37)) | ||
|
|
||
| // Overloaded functions with no default type arguments | ||
| declare function f2<A>(): void; | ||
| >f2 : Symbol(f2, Decl(functionTypeArgumentArityErrors.ts, 4, 45), Decl(functionTypeArgumentArityErrors.ts, 7, 31)) | ||
| >A : Symbol(A, Decl(functionTypeArgumentArityErrors.ts, 7, 20)) | ||
|
|
||
| declare function f2<A, B, C>(): void; | ||
| >f2 : Symbol(f2, Decl(functionTypeArgumentArityErrors.ts, 4, 45), Decl(functionTypeArgumentArityErrors.ts, 7, 31)) | ||
| >A : Symbol(A, Decl(functionTypeArgumentArityErrors.ts, 8, 20)) | ||
| >B : Symbol(B, Decl(functionTypeArgumentArityErrors.ts, 8, 22)) | ||
| >C : Symbol(C, Decl(functionTypeArgumentArityErrors.ts, 8, 25)) | ||
|
|
||
| f2<number, number>(); | ||
| >f2 : Symbol(f2, Decl(functionTypeArgumentArityErrors.ts, 4, 45), Decl(functionTypeArgumentArityErrors.ts, 7, 31)) | ||
|
|
||
| f2<number, number, number, number>(); | ||
| >f2 : Symbol(f2, Decl(functionTypeArgumentArityErrors.ts, 4, 45), Decl(functionTypeArgumentArityErrors.ts, 7, 31)) | ||
|
|
||
| // Overloaded non-generic functions | ||
| declare function f3(): void; | ||
| >f3 : Symbol(f3, Decl(functionTypeArgumentArityErrors.ts, 10, 37), Decl(functionTypeArgumentArityErrors.ts, 13, 28)) | ||
|
|
||
| declare function f3(a): void; | ||
| >f3 : Symbol(f3, Decl(functionTypeArgumentArityErrors.ts, 10, 37), Decl(functionTypeArgumentArityErrors.ts, 13, 28)) | ||
| >a : Symbol(a, Decl(functionTypeArgumentArityErrors.ts, 14, 20)) | ||
|
|
||
| f3<number>(); | ||
| >f3 : Symbol(f3, Decl(functionTypeArgumentArityErrors.ts, 10, 37), Decl(functionTypeArgumentArityErrors.ts, 13, 28)) | ||
|
|
||
| // Generic function with default type parameters | ||
| declare function f4<A, B, C = any>(): void; | ||
| >f4 : Symbol(f4, Decl(functionTypeArgumentArityErrors.ts, 15, 13)) | ||
| >A : Symbol(A, Decl(functionTypeArgumentArityErrors.ts, 18, 20)) | ||
| >B : Symbol(B, Decl(functionTypeArgumentArityErrors.ts, 18, 22)) | ||
| >C : Symbol(C, Decl(functionTypeArgumentArityErrors.ts, 18, 25)) | ||
|
|
||
| f4<number>(); | ||
| >f4 : Symbol(f4, Decl(functionTypeArgumentArityErrors.ts, 15, 13)) | ||
|
|
||
| f4<number, number, number, number>(); | ||
| >f4 : Symbol(f4, Decl(functionTypeArgumentArityErrors.ts, 15, 13)) | ||
|
|
||
| // Generic function with no default type arguments | ||
| declare function f5<A, B>(): void; | ||
| >f5 : Symbol(f5, Decl(functionTypeArgumentArityErrors.ts, 20, 37)) | ||
| >A : Symbol(A, Decl(functionTypeArgumentArityErrors.ts, 23, 20)) | ||
| >B : Symbol(B, Decl(functionTypeArgumentArityErrors.ts, 23, 22)) | ||
|
|
||
| f5<number>(); | ||
| >f5 : Symbol(f5, Decl(functionTypeArgumentArityErrors.ts, 20, 37)) | ||
|
|
||
| f5<number, number, number>(); | ||
| >f5 : Symbol(f5, Decl(functionTypeArgumentArityErrors.ts, 20, 37)) | ||
|
|
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/functionTypeArgumentArityErrors.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| === tests/cases/compiler/functionTypeArgumentArityErrors.ts === | ||
| // Overloaded functions with default type arguments | ||
| declare function f1<A = any>(): void; | ||
| >f1 : { <A = any>(): void; <A, B, C, D = any>(): void; } | ||
|
|
||
| declare function f1<A, B, C, D = any>(): void; | ||
| >f1 : { <A = any>(): void; <A, B, C, D = any>(): void; } | ||
|
|
||
| f1<number, number>(); | ||
| >f1<number, number>() : any | ||
| >f1 : { <A = any>(): void; <A, B, C, D = any>(): void; } | ||
|
|
||
| f1<number, number, number, number, number>(); | ||
| >f1<number, number, number, number, number>() : any | ||
| >f1 : { <A = any>(): void; <A, B, C, D = any>(): void; } | ||
|
|
||
| // Overloaded functions with no default type arguments | ||
| declare function f2<A>(): void; | ||
| >f2 : { <A>(): void; <A, B, C>(): void; } | ||
|
|
||
| declare function f2<A, B, C>(): void; | ||
| >f2 : { <A>(): void; <A, B, C>(): void; } | ||
|
|
||
| f2<number, number>(); | ||
| >f2<number, number>() : any | ||
| >f2 : { <A>(): void; <A, B, C>(): void; } | ||
|
|
||
| f2<number, number, number, number>(); | ||
| >f2<number, number, number, number>() : any | ||
| >f2 : { <A>(): void; <A, B, C>(): void; } | ||
|
|
||
| // Overloaded non-generic functions | ||
| declare function f3(): void; | ||
| >f3 : { (): void; (a: any): void; } | ||
|
|
||
| declare function f3(a): void; | ||
| >f3 : { (): void; (a: any): void; } | ||
| >a : any | ||
|
|
||
| f3<number>(); | ||
| >f3<number>() : any | ||
| >f3 : { (): void; (a: any): void; } | ||
|
|
||
| // Generic function with default type parameters | ||
| declare function f4<A, B, C = any>(): void; | ||
| >f4 : <A, B, C = any>() => void | ||
|
|
||
| f4<number>(); | ||
| >f4<number>() : any | ||
| >f4 : <A, B, C = any>() => void | ||
|
|
||
| f4<number, number, number, number>(); | ||
| >f4<number, number, number, number>() : any | ||
| >f4 : <A, B, C = any>() => void | ||
|
|
||
| // Generic function with no default type arguments | ||
| declare function f5<A, B>(): void; | ||
| >f5 : <A, B>() => void | ||
|
|
||
| f5<number>(); | ||
| >f5<number>() : any | ||
| >f5 : <A, B>() => void | ||
|
|
||
| f5<number, number, number>(); | ||
| >f5<number, number, number>() : any | ||
| >f5 : <A, B>() => void | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| tests/cases/compiler/newMap.ts(1,9): error TS2558: Expected 0-2 type arguments, but got 1. | ||
| tests/cases/compiler/newMap.ts(1,9): error TS2743: No overload expects 1 type arguments, but overloads do exist that expect either 0 or 2 type arguments. | ||
|
|
||
|
|
||
| ==== tests/cases/compiler/newMap.ts (1 errors) ==== | ||
| new Map<string>(); | ||
| ~~~~~~ | ||
| !!! error TS2558: Expected 0-2 type arguments, but got 1. | ||
| !!! error TS2743: No overload expects 1 type arguments, but overloads do exist that expect either 0 or 2 type arguments. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Overloaded functions with default type arguments | ||
| declare function f1<A = any>(): void; | ||
| declare function f1<A, B, C, D = any>(): void; | ||
| f1<number, number>(); | ||
| f1<number, number, number, number, number>(); | ||
|
|
||
| // Overloaded functions with no default type arguments | ||
| declare function f2<A>(): void; | ||
| declare function f2<A, B, C>(): void; | ||
| f2<number, number>(); | ||
| f2<number, number, number, number>(); | ||
|
|
||
| // Overloaded non-generic functions | ||
| declare function f3(): void; | ||
| declare function f3(a): void; | ||
| f3<number>(); | ||
|
|
||
| // Generic function with default type parameters | ||
| declare function f4<A, B, C = any>(): void; | ||
| f4<number>(); | ||
| f4<number, number, number, number>(); | ||
|
|
||
| // Generic function with no default type arguments | ||
| declare function f5<A, B>(): void; | ||
| f5<number>(); | ||
| f5<number, number, number>(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this to the previous message? The only reason I see for the new message is that before, the expected was either min or min–max. Now expected is either above or below, but above is the common case anyway, and means basically the same as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is consistent with the other new message when there are overloads, but I suppose the old message is fine as well.