Fix type error in ISpritesheetData#9896
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6e4ab7d:
|
|
What version of typescript? Do have a reproduction of the type error? What about using |
Here's a reproducible example: https://gist.github.com/Nearoo/83c5190c075a12c3e2e8464d43eb5763 It will result in: I don't think I understand your concern though. Maybe a better approach would be to change the type of the |
|
Yes, the problem is on the Spritesheet class not the data interface. |
|
Alright, update my branch. Would be cool if you could merge, we have a lot of |
Description of change
Removes the
?on theanimationskey of theISpritesheetDatatype. This is because it results in the typeRecord<never, ...>for theSpritesheetclass memberanimationshere, making it impossible to useanimationswithout type error in typescript.The reason for this is that
animationofISpritesheetDatais of typeRecord<keyof S['animations'], Texture[]>, where, due to the?,keyof S['animations']will evaluate toundefined & utils.Dict<string[]>, which isnever.Since
Spritesheet.animationsis always initialized (here), it shouldn't cause an issue. However, I don't have a broad overview over the codebase, someone might want to verify that.Pre-Merge Checklist
I didn't add any tests because the error is on a type level, and the change is literally one character.
npm run lint)npm run test)