greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.84k stars 1.72k forks source link

Declaration for gsap/all #395

Closed Rechdan closed 4 years ago

Rechdan commented 4 years ago

I was having issues with "gsap/all" being not declared, so I made this declaration file:

declare module 'gsap/all' {
    import gsap from 'gsap';
    import CSSPlugin from 'gsap/CSSPlugin';

    var gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap, // to protect from tree shaking
        TweenMaxWithCSS = gsapWithCSS.core.Tween;

    export { gsapWithCSS as gsap, gsapWithCSS as default, CSSPlugin, TweenMaxWithCSS as TweenMax };

    export { TweenLite, TimelineMax, TimelineLite, Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, Strong, Elastic, Back, SteppedEase, Bounce, Sine, Expo, Circ, wrap, wrapYoyo, distribute, random, snap, normalize, getUnit, clamp, splitColor, toArray, mapRange, pipe, unitize, interpolate, shuffle } from 'gsap/gsap-core';

    export * from 'gsap/Draggable';
    export * from 'gsap/CSSRulePlugin';
    export * from 'gsap/EaselPlugin';
    export * from 'gsap/EasePack';
    export * from 'gsap/MotionPathPlugin';
    export * from 'gsap/PixiPlugin';
    export * from 'gsap/ScrollToPlugin';
    export * from 'gsap/ScrollTrigger';
    export * from 'gsap/TextPlugin';
}

Not sure if it really covers everything, I copied and modified the content from all.js, but now VS Code is recognizing it 😁

OSUblake commented 4 years ago

It's already declared, but it has trouble finding it for some reason. 🤷‍♂️

If you import from gsap at least one time, it will find the declarations, or you can specify where the declarations are in your tsconfig.

{
  "compilerOptions": {
    ...
  },
  "files": [
    "node_modules/gsap/types/index.d.ts"
  ]
}
Rechdan commented 4 years ago

It's already declared, but it has trouble finding it for some reason. 🤷‍♂️

If you import from gsap at least one time, it will find the declarations, or you can specify where the declarations are in your tsconfig.

{
  "compilerOptions": {
    ...
  },
  "files": [
    "node_modules/gsap/types/index.d.ts"
  ]
}

Don't knew that hack, thanks for sharing it!