Registry Mirror
Skip to content

Conversation

@hkbughk

@hkbughk hkbughk commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #7396.

getTileAt, getTileAtWorldXY, getIsoTileAtWorldXY, removeTileAt, removeTileAtWorldXY and findByIndex on TilemapLayerBase (and so TilemapLayer and TilemapGPULayer), plus the GetTileAt, GetTileAtWorldXY, RemoveTileAt and RemoveTileAtWorldXY components, can all return null. This happens when the coordinates are out of bounds, the tile is empty and nonNull is false, or no match is found. Their JSDoc @return type was {Phaser.Tilemaps.Tile}, so the generated .d.ts didn't include | null, and TypeScript accepted unsafe code like layer.getTileAt(x, y).index.

This changes the return types to {?Phaser.Tilemaps.Tile}, matching the equivalent Tilemap methods and the FindByIndex component. Only documentation and types change, not runtime behaviour. TypeScript users with strictNullChecks on may now need to null-check the result.

@photonstorm
photonstorm merged commit f972ba9 into phaserjs:master Dec 1, 2026
photonstorm added a commit that referenced this pull request Dec 1, 2026
… and CalculateFacesAt, which also return null for coordinates outside of the layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type definition for TilemapLayer.getTileAt is wrong

2 participants