Skip to content

Commit a1cf6e4

Browse files
committed
add generics for Scene and its config key
1 parent bf09e47 commit a1cf6e4

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/scene/Scene.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ var Systems = require('./Systems');
1717
* @memberof Phaser
1818
* @constructor
1919
* @since 3.0.0
20+
*
21+
* @generic {string=string} K
22+
* @genericUse {K | Phaser.Types.Scenes.SettingsConfig.<K>} - [config]
2023
*
2124
* @param {(string|Phaser.Types.Scenes.SettingsConfig)} config - Scene specific configuration settings.
2225
*/

src/scene/typedefs/SettingsConfig.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/**
22
* @typedef {object} Phaser.Types.Scenes.SettingsConfig
33
* @since 3.0.0
4+
*
5+
* @generic {string=string} K - [key]
46
*
5-
* @property {string} [key] - The unique key of this Scene. Must be unique within the entire Game instance.
7+
* @property {K} [key] - The unique key of this Scene. Must be unique within the entire Game instance.
68
* @property {boolean} [active=false] - Does the Scene start as active or not? An active Scene updates each step.
79
* @property {boolean} [visible=true] - Does the Scene start as visible or not? A visible Scene renders each step.
810
* @property {(false|Phaser.Types.Loader.FileTypes.PackFileConfig)} [pack=false] - An optional Loader Packfile to be loaded before the Scene begins.

types/phaser.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50758,7 +50758,7 @@ declare namespace Phaser {
5075850758
/**
5075950759
* If provided as an array, the range defined by `start` and `end` will be ignored and these frame numbers will be used.
5076050760
*/
50761-
frames?: boolean;
50761+
frames?: boolean | integer[];
5076250762
};
5076350763

5076450764
type GenerateFrameNumbers = {
@@ -55726,11 +55726,11 @@ declare namespace Phaser {
5572655726
data?: any;
5572755727
};
5572855728

55729-
type SettingsConfig = {
55729+
type SettingsConfig<K extends string = string> = {
5573055730
/**
5573155731
* The unique key of this Scene. Must be unique within the entire Game instance.
5573255732
*/
55733-
key?: string;
55733+
key?: K;
5573455734
/**
5573555735
* Does the Scene start as active or not? An active Scene updates each step.
5573655736
*/
@@ -74723,12 +74723,12 @@ declare namespace Phaser {
7472374723
*
7472474724
* You can also define the optional methods {@link Phaser.Types.Scenes.SceneInitCallback init()}, {@link Phaser.Types.Scenes.ScenePreloadCallback preload()}, and {@link Phaser.Types.Scenes.SceneCreateCallback create()}.
7472574725
*/
74726-
class Scene {
74726+
class Scene<K extends string = string> {
7472774727
/**
7472874728
*
7472974729
* @param config Scene specific configuration settings.
7473074730
*/
74731-
constructor(config: string | Phaser.Types.Scenes.SettingsConfig);
74731+
constructor(config: K | Phaser.Types.Scenes.SettingsConfig<K>);
7473274732

7473374733
/**
7473474734
* The Scene Systems. You must never overwrite this property, or all hell will break lose.

0 commit comments

Comments
 (0)