phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.16k stars 7.1k forks source link

SceneManager.getScene has wrong return type in ts definition #6821

Closed vankop closed 2 months ago

vankop commented 6 months ago

Version

Description

SceneManager.getScene has wrong return type in ts definition. see types/phaser.d.ts. Should be Phaser.Scene if typeof key === "string"

Example Test Code

Additional Information

zekeatchan commented 5 months ago

Hi @vankop, kindly provide test code examples so we can investigate further and have a better understanding of the issue you're facing. Thanks!

photonstorm commented 2 months ago

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

BenAfonso commented 2 weeks ago

This seems to have broken the type definition in 3.86.0:

Behaviour:

SceneManager.getScene<T extends Phaser.Scene>(key: (T|string)): Phaser.Scene | null

ScenePlugin.get<T extends Phaser.Scene>(key: (T|string)): Phaser.Scene;

Expected:

SceneManager.getScene<T extends Phaser.Scene>(key: (T|string)): T | null

ScenePlugin.get<T extends Phaser.Scene>(key: (T|string)): T | null;