Skip to content

{CallableFunction, NewableFunction}.bind failed to infer overload and generic functions for zero-arguments binding #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
graphemecluster opened this issue Jul 11, 2022 · 0 comments · Fixed by #16

Comments

@graphemecluster
Copy link
Contributor

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;
}
@graphemecluster graphemecluster changed the title {CallableFunction, NewableFunction}.bind failed to infer overload and generic functions {CallableFunction, NewableFunction}.bind failed to infer overload and generic functions for zero-arguments binding Jul 11, 2022
@uhyo uhyo closed this as completed in #16 Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant