pixijs / spine

Pixi.js plugin that enables Spine support.
Other
564 stars 217 forks source link

3.0.2 + 3.0.3 broken with TypeScript #395

Closed qtiki closed 3 years ago

qtiki commented 3 years ago

The published @pixi-spine/runtime-3.8 package is broken with TypeScript since 3.0.2. When trying to use it in a TypeScript project the types give the following error:

node_modules/@pixi-spine/runtime-3.8/index.d.ts:245:5 - error TS2416: Property 'getMix' in type 'AnimationStateData' is not assignable to the same property in base type 'IAnimationStateData'.
  Type '(from: Animation_2, to: Animation_2) => number' is not assignable to type '(from: Animation, to: Animation) => number'.
    Types of parameters 'from' and 'from' are incompatible.
      Type 'Animation' is missing the following properties from type 'Animation_2': name, timelines, timelineIds, duration, and 2 more.

245     getMix(from: Animation_2, to: Animation_2): number;
        ~~~~~~

I investigated the types in node_modules and it seems that @pixi-spine/runtime-3.8/index.d.ts where it has class AnimationStateData implements IAnimationStateData the file has a definition for Animation_2. However if I go to declaration where IAnimationStateData is declared in @pixi-spine/base/index.d.ts there is no declaration for Animation. This doesn't give an error though since it actually refers to the DOM type Animation but obviously that causes the implements to error.

I'm not sure how the types are generated so I don't know where to fix this but I suppose the fix itself shouldn't be that complicated.

ivanpopelyshev commented 3 years ago

I think I fixed this bug in 3.0.3 , can you check again? reinstall all the modules e.t.c.

qtiki commented 3 years ago

Still happens after I delete yarn.lock and node_modules and reinstall.

I've checked that the version in node_modules/@pixi-spine/runtime-3.8/package.json is 3.0.3 and here's the output from yarn why @pixi-spine/runtime-3.8:

>yarn why @pixi-spine/runtime-3.8
yarn why v1.22.5
[1/4] Why do we have the module "@pixi-spine/runtime-3.8"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@pixi-spine/runtime-3.8@3.0.3"
info Has been hoisted to "@pixi-spine/runtime-3.8"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "2.19MB"
info Disk size with unique dependencies: "2.64MB"
info Disk size with transitive dependencies: "2.64MB"
info Number of shared dependencies: 1
Done in 0.09s.
qtiki commented 3 years ago

Oh and @pixi-spine/base version is definitely 3.0.3 too.

ivanpopelyshev commented 3 years ago

hm, base/index.d.ts is old somehow. Gonna fix it and re-release 3.0.4

ivanpopelyshev commented 3 years ago

OK, please try 3.0.4

I'm not accustomed to new build tools yet. Also making pixi-spine universal and separating it into modules took its toll, and so far you're the first one who actually goes into details on whats wrong. I expected more help from webpack-lovers

qtiki commented 3 years ago

3.0.4 compiles without errors. Thanks for the quick response!

We're still in the process of converting everything from PIXI v5 to v6 and from pixi.js import to individual packages (now that the type definitions work for them) so I can't yet say if everything actually works - but having no compiler errors is definitely a good start.

And I have to say that I like the new module split very much so thank you for that too! Also looking forward to testing the 4.0 runtime too once the smoke clears from the v6 conversion stuff.

ivanpopelyshev commented 3 years ago

i found a few strange things in 4.0 and cant confirm whether its mine or esotericsoftware bugs :)

I also recommend to use @pixi-spine/all-3.8 if you dont experiment - that bundle is smaller and re-exports things from runtime-3.8.

Please tell me if you need help with other plugins

qtiki commented 3 years ago

We're currently using @pixi-spine/all-3.8. However we don't need any of the loader stuff since we have some custom loading happening so I figured that the runtime and base would be smaller. Haven't really had a chance to look into how Webpack's tree-shaking works with the individual modules and all.

Regarding the other plugins we're probably going to need pixi-projection and pixi-particles for v6 as well. I've opened an issue to pixi-particles for that but not for pixi-projection.