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
I've been messing around with the new variadic tuple types and I noticed some odd behavior around overloads and type inference (I may just be doing something incorrect in my types).
I wrote a higher order function that converts the popular "callback" format into a promise. However, if the function is overloaded, the resulting type seems the be the second to last overloaded signature (the one before the actual implementation).
I guess I'm not surprised this doesn't work, but I just wanted to report as I think it's something that other may run into.
The type of readFilePromise would retain the overloads.
Actual behavior:
const readFilePromise: (file: string, type: number) => Promise<string>. If you switch the top 2 signatures of readFile, it will update to const readFilePromise: (file: string) => Promise 🤷♂️
I've been messing around with the new variadic tuple types and I noticed some odd behavior around overloads and type inference (I may just be doing something incorrect in my types).
I wrote a higher order function that converts the popular "callback" format into a promise. However, if the function is overloaded, the resulting type seems the be the second to last overloaded signature (the one before the actual implementation).
I guess I'm not surprised this doesn't work, but I just wanted to report as I think it's something that other may run into.
TypeScript Version: 4.0.0-dev.20200803
Search Terms:
variadic, tuple, overload
Code
Expected behavior:
The type of
readFilePromise
would retain the overloads.Actual behavior:
const readFilePromise: (file: string, type: number) => Promise<string>
. If you switch the top 2 signatures ofreadFile
, it will update to const readFilePromise: (file: string) => Promise 🤷♂️Playground Link:
Playground Link
Related Issues:
#35641
The text was updated successfully, but these errors were encountered: