-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Overload signature that uses generics breaks as of 2.7.1 #22075
Comments
I suspect you're right about that. You can get around this by explicitly saying that |
@DanielRosenwasser - yes: function fooWrapper(values) {
return foo(values) as any[];
}
const result = fooWrapper([1,2]); // [number, number] or even function fooWrapper(values) {
return foo(values) as any;
}
const result = fooWrapper([1,2]); // [number, number] solves the issue while retaining typings. I added this because it broke our CI and figured it might do the same for someone else later. |
ideally, you would give |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.7.1, 2.7.2, 2.8.0-dev.20180220; issue not present in 2.6.2
Search Terms: overload, signature, generic, tuple
Code:
Expected behavior:
There should not be any type error; the wrapping function should behave identically to the wrapped function.
Actual behavior:
Compile time error on the overload signature of the wrapping function.
Playground Link: http://www.typescriptlang.org/play/#src=function%20foo%3CT1%2C%20T2%3E(values%3A%20%5BT1%2C%20T2%5D)%3A%20%5BT1%2C%20T2%5D%3B%0D%0Afunction%20foo%3CT1%3E(values%3A%20%5BT1%5D)%3A%20%5BT1%5D%3B%0D%0Afunction%20foo(values)%20%7B%0D%0A%09return%20values%3B%0D%0A%7D%0D%0A%0D%0Afunction%20fooWrapper%3CT1%2C%20T2%3E(values%3A%20%5BT1%2C%20T2%5D)%3A%20%5BT1%2C%20T2%5D%3B%0D%0A%2F**%20%5Bts%5D%20Overload%20signature%20is%20not%20compatible%20with%20function%20implementation.%20**%2F%0D%0Afunction%20fooWrapper%3CT1%3E(values%3A%20%5BT1%5D)%3A%20%5BT1%5D%3B%0D%0Afunction%20fooWrapper(values)%20%7B%0D%0A%09return%20foo(values)%3B%0D%0A%7D
Related Issues: None known
Notes: Seems potentially related to tuples fixed length change in 2.7
The text was updated successfully, but these errors were encountered: