TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms: mapped type overload
Code
interfaceOverloads{foo(a: string): void;foo(a: number,b: string): void;}/** Converts all properties of an object to Promises and all methods to return Promises */typeProxiedObject<T>={[PinkeyofT]: T[P]extends(...args: infer Arguments)=> infer R
? (...args: Arguments)=>Promise<R>
: Promise<T[P]>};declareletx: ProxiedObject<Overloads>;x.foo("abc");// Error: [ts] Expected 2 arguments, but got 1. [2554]x.foo(123,"abc");Expected behavior:
No error, overload should be maintained.
This makes it impossible to use this pattern with popular types that contain overloads, like Rx Observablepipe()/subscribe().
The ProxiedObject type is used in https://github.com/GoogleChromeLabs/comlink.
Actual behavior:
Overload gets lost, compile error when trying to call the first overload.
Playground Link:link
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms: mapped type overload
Code
Expected behavior:
No error, overload should be maintained.
This makes it impossible to use this pattern with popular types that contain overloads, like Rx
Observablepipe()/subscribe().The
ProxiedObjecttype is used in https://github.com/GoogleChromeLabs/comlink.Actual behavior:
Overload gets lost, compile error when trying to call the first overload.
Playground Link:link