Jump to content
Search Community

gsap.DOMTarget (Typescript d.ts) doesn't include "window"

iDad5 test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

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

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. 

 

  • 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.
×
×
  • Create New...