Share Posted July 6, 2022 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 More sharing options...
Share Posted July 6, 2022 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 More sharing options...
Author Share Posted October 17, 2022 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 More sharing options...
Share Posted October 17, 2022 Hi, I'm not well versed in TS neither, but maybe this is what you're looking for: https://github.com/greensock/GSAP/blob/master/types/gsap-core.d.ts#L531-L568 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! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now