Skip to content

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

Closed
@graphemecluster

Description

@graphemecluster

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions