iDad5 Posted April 25, 2022 Share Posted April 25, 2022 Hi all, I was trying to use the Observer-Plugin in and wanted to set the target to window, but TypeScript informed me that window wasn't a valid gsap.DOMTarget which seemed logical when inspecting the gsap-core.d.ts. I temporarily added Eventtarget to type DOMTarget in my project, and speculate that that might be a good idea - or not? Anyhow I would love to see a fix, or be educated how to do better. THX Link to comment Share on other sites More sharing options...
Cassie Posted April 25, 2022 Share Posted April 25, 2022 Heya! By default Observer uses the window so I'm not really sure what the issue here is. Maybe it's a typescript thing? There's a typescript community here which may be able to help - https://discord.com/invite/typescript?utm_source=devglan Link to comment Share on other sites More sharing options...
iDad5 Posted April 25, 2022 Author Share Posted April 25, 2022 it is indeed a typescript thing. But it is a bug or an oversight in the Typescript-definitions provided (by Greensock) for the Observer-Plugin. The type of the target in the interface ObserverVars is provided as gsap.DomTarget, which in turn can be either an Element, a string, null or an Array(Like); window however is neither of those. Therefore Typescript throws an error when trying to transpile. Your hint that window is the default provides a possible solution - just not write it out. I would rather not go down that road however. I have for now solved the problem by extending the definition for gsap.DOMTarget with EventTarget but that might be to broad. Maybe just allowing window in addition to gsap.DOMTarget in the observer-definitions would be wiser. Or adding window to gsap.DOMTarget as this problem might extend to other areas? As far as I understand it Blake used to fix similar problems in the past and I'm sure he or whomever maintains the Typescript- definitions will have a good solution to be included in the next Update. 1 Link to comment Share on other sites More sharing options...
Cassie Posted April 25, 2022 Share Posted April 25, 2022 Ah ok gotcha! Well, Blake will be around shortly. Link to comment Share on other sites More sharing options...
Solution OSUblake Posted April 25, 2022 Solution Share Posted April 25, 2022 Yeah, it's just an oversite, and I'll add a window to the DOMTarget for the next release. 2 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