You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
functionfoo<T1,T2>(values: [T1,T2]): [T1,T2];functionfoo<T1>(values: [T1]): [T1];functionfoo(values){returnvalues;}functionfooWrapper<T1,T2>(values: [T1,T2]): [T1,T2];/** [ts] Overload signature is not compatible with function implementation. **/functionfooWrapper<T1>(values: [T1]): [T1];functionfooWrapper(values){returnfoo(values);}
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.
ideally, you would give values a type annotation to be [any] | [any, any], and expect the type of foo(values) to be [any]|[any, any]. The issue here is that overload resolution does not distribute over union properties, so that is not possible today. this is tracked by #14107
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: