spine icon indicating copy to clipboard operation
spine copied to clipboard

Runtime 4.1 does not play nice with TypeScript strict mode

Open qtiki opened this issue 1 year ago • 2 comments

Trying to use the runtime 4.1 with strict: enabled causes a bunch of errors like this:

node_modules/@pixi-spine/runtime-4.1/index.d.ts:78:64 - error TS2344: Type 'AnimationStateData' does not satisfy the constraint 'IAnimationStateData<ISkeletonData<IBoneData, ISlotData, ISkin, IAnimation<ITimeline>, IEventData, IIkConstraintData, ITransformConstraintData, IPathConstraintData>, IAnimation<...>>'.
  The types of 'skeletonData.name' are incompatible between these types.
    Type 'string | null' is not assignable to type 'string'.
      Type 'null' is not assignable to type 'string'.

78 export declare class AnimationState implements IAnimationState<AnimationStateData> {
                                                                  ~~~~~~~~~~~~~~~~~~

Older runtimes 4.0 and 3.8 compile correctly even with the strict mode.

qtiki avatar Feb 01 '24 13:02 qtiki

Easiest way to reproduce/fix these issues is to enable strictNullChecks: true in the project's tsconfig.json. That'll throw a bunch of compile errors.

Though looking at the core Pixi.js repository it doesn't seem to have strict null checks enabled either. It would be great if these packages would be fully strict mode compliant.

qtiki avatar Feb 01 '24 13:02 qtiki

Okay seems like there is already an issue about this for Pixi itself: https://github.com/pixijs/pixijs/issues/8852

qtiki avatar Feb 01 '24 14:02 qtiki