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
ReturnType (and conditional types on signatures in general) only operate on single overload. For intersection, union or overloads, the first is always picked.
TypeScript Version: 2.9.2 and 3.0.0-dev.20180705
Search Terms:
typescript intersection ReturnType
Code
Expected behavior:
I would expect Test2 to be a union of ReturnType of "foo" and "bar"
Actual behavior:
I only get the ReturnType of "bar"
Playground Link:
http://www.typescriptlang.org/play/#src=const%20foo%20%3D%20()%20%3D%3E%20(%7B%0D%0A%20%20%20%20foo%3A%20'bar'%0D%0A%7D)%0D%0A%0D%0Aconst%20bar%20%3D%20()%20%3D%3E%20(%7B%0D%0A%20%20%20%20bar%3A%20'baz'%0D%0A%7D)%0D%0A%0D%0Atype%20Test%20%3D%20typeof%20foo%20%26%20typeof%20bar%0D%0A%0D%0Atype%20Test2%20%3D%20ReturnType%3CTest%3E%0D%0A
You will have to excuse if I am being ignorant on this and it actually is expected behaviour :-)
The text was updated successfully, but these errors were encountered: