TS error: Can't assign Layer to Container
tustin2121 opened this issue · 4 comments
I'm getting a lot of annoying TypeScript errors in my project when I attempt to use the @pixi/layers package with Pixi.js 6.0.4. This seems to be the root cause in https://github.com/pixijs/pixi-layers/blob/master/index.d.ts#L79
Property 'renderCanvas' in type 'Layer' is not assignable to the same property in base type 'Container'.
Type '(renderer: ILayeredRenderer) => void' is not assignable to type '(renderer: CanvasRenderer) => void'.
Types of parameters 'renderer' and 'renderer' are incompatible.
Type 'CanvasRenderer' is missing the following properties from type 'ILayeredRenderer': _lastDisplayOrder, _activeLayer, incDisplayOrder, _oldRenderts(2416)
I'm unsure how to fix this problem as I'm new to TypeScript (and am ready to abandon it shortly with how much of a pain it's been over normal js so far, tbh...).
EDIT: Commenting out the line makes the error go away. I'm sure that's not how this is supposed to be fixed, but that's a workaround I guess for now...
I keep getting that error too. Its not really typescript's fault, just a type incompatibility between PIXI's default stage (PIXI.Container
) and the Stage
offered by pixi-layers.
Instead of commenting out something in a dependency (your change would be gone on next npm install
), you could add // @ts-ignore
one line before error (there would be a few more)
Oh, that's a new bug I have introduced :) gonna fix it
published 1.0.6 , plesae try again
That did indeed fix the problem. Thanks!
Instead of commenting out something in a dependency (your change would be gone on next
npm install
), you could add// @ts-ignore
one line before error (there would be a few more)
Oh I'm fully aware of how dependancies work. I'm not new to the NPM game, just TS specifically. And I was irritated that I would have had to put a @ts-ignore on like five consecutive lines because every time I added another Layer to the Stage, ts was throwing the error. (And it was nearly midnight and I was cranky, and I've already had quite a few more annoyances with ts than this.)
But anyway, thanks for the fast response.