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
Expected behavior:
Expected stub1 and stub2 to be compiled without any error.
Actual behavior:
Both stub1 and stub2 shows
Type '(_a: string) => boolean' is not assignable to type '(a: boolean) => any'.
Types of parameters '_a' and 'a' are incompatible.
Type 'boolean' is not assignable to type 'string'. [2322]
Related Issues: #13570
The closest I can find is this but it has generic types at the first function's signature, I am not sure fundamentally do they refer to the same issue.
The text was updated successfully, but these errors were encountered:
calvinlauyh
changed the title
Only the last signature of an overloaded function is return in Parameters<T>
Only the last signature of an overloaded function is allowed in Parameters<T>
Dec 1, 2018
When inferring from a type with multiple call signatures (such as the type of an overloaded function), inferences are made from the last signature (which, presumably, is the most permissive catch-all case). It is not possible to perform overload resolution based on a list of argument types.
TypeScript Version: 3.2.1
Search Terms:
overloaded function
.overloaded signature
,overloaded arguments
Code
Expected behavior:
Expected
stub1
andstub2
to be compiled without any error.Actual behavior:
Both
stub1
andstub2
showsPlayground Link:
http://www.typescriptlang.org/play/#src=function%20testFn(a%3A%20string)%3A%20boolean%3B%0D%0Afunction%20testFn(a%3A%20number)%3A%20boolean%3B%0D%0Afunction%20testFn(a%3A%20boolean)%3A%20boolean%3B%0D%0Afunction%20testFn(_a%3A%20string%20%7C%20number%20%7C%20boolean)%3A%20boolean%20%7B%0D%0A%20%20return%20true%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20Stub%20%7B%0D%0A%20%20callsFake(...args%3A%20Parameters%3Ctypeof%20testFn%3E)%3A%20void%0D%0A%7D%0D%0A%0D%0Aconst%20stub1%3A%20Stub%20%3D%20%7B%0D%0A%20%20callsFake(_a%3A%20string)%3A%20boolean%20%7B%0D%0A%20%20%20%20return%20true%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0Aconst%20stub2%3A%20Stub%20%3D%20%7B%0D%0A%20%20callsFake(_a%3A%20number)%3A%20boolean%20%7B%0D%0A%20%20%20%20return%20true%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0Aconst%20stub3%3A%20Stub%20%3D%20%7B%0D%0A%20%20callsFake(_a%3A%20boolean)%3A%20boolean%20%7B%0D%0A%20%20%20%20return%20true%3B%0D%0A%20%20%7D%0D%0A%7D
Related Issues:
#13570
The closest I can find is this but it has generic types at the first function's signature, I am not sure fundamentally do they refer to the same issue.
The text was updated successfully, but these errors were encountered: