better-typescript-lib
better-typescript-lib copied to clipboard
`{CallableFunction, NewableFunction}.bind` failed to infer overload and generic functions for zero-arguments binding
https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/functions/strictBindCallApply1.ts
Fix:
--- es5.d.ts
+++ es5.d.ts
interface CallableFunction extends Function {
@@ @@
+ /**
+ * For a given function, creates a bound function that has the same body as the original function.
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
+ * @param thisArg The object to be used as the this object.
+ */
+ bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<T, A extends any[], B extends any[], R>(this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R;
}
interface NewableFunction extends Function {
@@ @@
+ /**
+ * For a given function, creates a bound function that has the same body as the original function.
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
+ * @param thisArg The object to be used as the this object.
+ */
+ bind<T>(this: T, thisArg: any): T;
/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<A extends any[], B extends any[], R>(this: new (...args: [...A, ...B]) => R, thisArg: any, ...args: A): new (...args: B) => R;
}