Jump to content


Adding Typescript definition for registerEffect

Recommended Posts

How to add custom typings when registering an effect? it would be very helpful if the custom effect is properly type not just set to any.

Link to comment
Share on other sites

That sounds like something you'd need to do on your end, right? I'm not much of a TypeScript expert, but since registerEffect() is inherently super flexible and allows people to build any effect that uses any properties, I'm not sure how we could add TypeScript definitions for that. Or perhaps I'm misunderstanding your question(?)

Link to comment
Share on other sites

  • 3 months later...

Hi, just wanted to ask if I made the proper way of extending the gsap.effects object? I created an effect using registerEffect and I have some props that I wanted to apply type safety when using gsap.effects.myEffect("property type inferred here")


declare namespace gsap {

  interface EffectsMap {
    [key: string]: any;
   	myEffect: ("properties here") => gsap.core.Timeline 
  const effects: EffectsMap;



Link to comment
Share on other sites



I'm not well versed in TS neither, but maybe this is what you're looking for:



Considering what has to be passed into the register effect method, creating an interface for that shouldn't be too complex, as far as I can tell, but again, not being a TS savant I couldn't tell you. But we're all ears when it comes to suggestions in making GSAP better and more robust, so you're more than welcome to chime in ideas that go in that direction.


Let us know how this work and if there's anything else we can do.


Happy Tweening!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.