Proposal: Make return values nullable for Gif.toSprite and TileMap.getTileByIndex methods #3166
Closed
ambmcmdmem626
started this conversation in
General
Replies: 1 comment 2 replies
-
@ambmcmdmem626 Thanks for the issue, I totally agree! |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Version: 0.29.3
Premise
If an index outside the array is specified for the following two methods,
either
undefined
is returned (TileMap.getTileByIndex
) or an exception is thrown (Gif.toSprite
).* Content of the Exception:
TypeError: Cannot read properties of undefined (reading 'toSprite')
Excalibur/src/engine/Resources/Gif.ts
Lines 79 to 86 in 2e4341f
Excalibur/src/engine/TileMap/TileMap.ts
Lines 459 to 464 in 2e4341f
Main topic
Is there a reason why the return values of these methods are not nullable?
I believe the issue can be addressed by modifying the code as shown below:
TileMap.getTileByPoint()
( link ).Suggested Code Changes
Thank you so much for reading this!
Beta Was this translation helpful? Give feedback.
All reactions