I have a module with a template like this:
export type UncurryThis<
T extends (this: unknown, ...args: unknown[]) => unknown
> = (self: ThisParameterType<T>, ...args: Parameters<T>) => ReturnType<T>
So for example, if you call uncurryThis(String.prototype.replace) then you'd have a method, so you can call stringPrototypeReplace('some string', ...) and it'll always use the captured uncurried method.
(The reason why is a long story, involving hardening some npm modules for eventual inclusion into node-core.)
The problem I'm facing is that the this-uncurried form of the function always seems to grab the last function overload. So, for example, UncurryThis<typeof Object.create> will think that it only has the type signature (o: object | null, properties: PropertyDescriptorMap<any>), instead of treating that second argument as optional (as it should).
Is there a way to extract the full set of function overloads for a given function type?