Skip to content

Phaser.Math.Pow2.GetPowerOfTwo is declared in phaser.d.ts but undefined at runtime in Phaser 4.1.0 #7309

@Visualizeit

Description

@Visualizeit

Version

  • Phaser Version: 4.1.0

  • Operating system: Windows

  • Browser: Chrome

Description

Phaser.Math.Pow2.GetPowerOfTwo is declared in phaser.d.ts, but it is undefined at runtime.

At runtime, Phaser.Math.Pow2 exposes GetNext, IsSize, and IsValue, but not GetPowerOfTwo.

Phaser.Math.Pow2.GetPowerOfTwo // undefined
Phaser.Math.Pow2.GetNext       // function

Expected behavior:

The runtime API and TypeScript declarations should match. Either GetPowerOfTwo should exist at runtime, or phaser.d.ts should declare GetNext instead.

Example Test Code

import Phaser from 'phaser';

console.log('Phaser version:', Phaser.VERSION);

console.log({
    GetPowerOfTwo: Phaser.Math.Pow2.GetPowerOfTwo
});

console.log({
    Pow2: Phaser.Math.Pow2
});

console.log({
    GetNext: Phaser.Math.Pow2.GetNext
});

Runtime result:

Image

TypeScript accepts this because GetPowerOfTwo exists in phaser.d.ts:

Phaser.Math.Pow2.GetPowerOfTwo(9);

But it fails at runtime because GetPowerOfTwo is undefined.

Additional Information

This appears to be a mismatch between the runtime export and the generated TypeScript declarations.

Runtime export appears to be:

module.exports = {
    GetNext: require('./GetPowerOfTwo'),
    IsSize: require('./IsSizePowerOfTwo'),
    IsValue: require('./IsValuePowerOfTwo')
};

But phaser.d.ts declares:

function GetPowerOfTwo(value: number): number;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions