GSAP icon indicating copy to clipboard operation
GSAP copied to clipboard

context.add typing issue

Open zakuk opened this issue 6 months ago • 0 comments

I believe there is a typing issue with the Context interface in gsap-core.d.ts

interface Context {
    ...
    add(methodName: string, func: Function, scope?: Element | string | object): Function;
    add(func: Function, scope?: Element | string | object): void;
   ...
  }

As I understand it the second overload (adding to the context immediately) should return the 'return value' of the function passed to func i.e.

interface Context {
    ...
    add(methodName: string, func: Function, scope?: Element | string | object): Function;
-   add(func: Function, scope?: Element | string | object): void;
+   add<T extends Function>(func: T, scope?: Element | string | object): ReturnType<T>;
   ...
  }

Or at least thats the way it works for me :)

Zak.

zakuk avatar Sep 05 '24 09:09 zakuk