phaser3-docs
phaser3-docs copied to clipboard
Clean the TypeDef and report an bug
Hello, I have an question : When the type is generate correctly we can move the types on phaser project for automaticly detect ?
I have this propositions for clean the TypeDef :
- Move the
typedeclaration in specific namespace - Merge object in same parent properties (look example n°1)
- ~~Trim the description (look example n°2)~~ (Fixed on this PR #9)
I have found potential bugs in the TypeDef :
- The functions in namespace (like
Actions) dont have prefixexport - In the description the optional param is not defined (example in example n°2)
- The description doesn't declare
@returnparam - ~~The module
phaseris not declared.~~ (This PR fix that #10)
Example n°1
In type JSONCamera you have :
declare type JSONCamera = {
[...]
/**
* The bounds of camera
*/
bounds: object;
/**
* The horizontal position of bounds of camera
*/
"bounds.x": number;
/**
* The vertical position of bounds of camera
*/
"bounds.y": number;
/**
* The width of the bounds of camera
*/
"bounds.width": number;
/**
* The height of the bounds of camera
*/
"bounds.height": number;
}
but we can clean the type for this :
declare type JSONCamera = {
[...]
/**
* The bounds of camera
*/
bounds: {
/**
* The horizontal position of bounds of camera
*/
x: number;
/**
* The vertical position of bounds of camera
*/
y: number;
/**
* The width of the bounds of camera
*/
width: number;
/**
* The height of the bounds of camera
*/
height: number;
};
}
Example n°2
In namespace Actions you have this description :
/**
* Takes an array of Game Objects, or any objects that have a public `angle` property,
*
* and then adds the given value to each of their `angle` properties.
*
*
*
* The optional `step` property is applied incrementally, multiplied by each item in the array.
*
*
*
* To use this with a Group: `Angle(group.getChildren(), value, step)`
* @param items The array of items to be updated by this action.
* @param value The amount to be added to the `angle` property.
* @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0.
* @param index An optional offset to start searching from within the items array. Default 0.
* @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1.
*/
function Angle<G extends Phaser.GameObjects.GameObject[]>(items: G, value: number, step?: number, index?: integer, direction?: integer): G;
but you can clean for that :
/**
* Takes an array of Game Objects, or any objects that have a public `angle` property,
* and then adds the given value to each of their `angle` properties.
*
* The optional `step` property is applied incrementally, multiplied by each item in the array.
*
* To use this with a Group: `Angle(group.getChildren(), value, step)`
*
* @param items The array of items to be updated by this action.
* @param value The amount to be added to the `angle` property.
* @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0.
* @param index An optional offset to start searching from within the items array. Default 0.
* @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1.
*/
function Angle<G extends Phaser.GameObjects.GameObject[]>(items: G, value: number, step?: number, index?: integer, direction?: integer): G;
Add bug :
- The generic type on callback is not right. Current version :
declare type EachListCallback<I extends *> = (item: any, ...args: any[])=>void;
declare type EachMapCallback<E extends *> = (key: string, entry: any)=>void;
declare type EachSetCallback<E extends *> = (entry: any, index: number)=>void;
Whanted version (+ the return value need nullable boolean) :
declare type EachListCallback<I extends any> = (item: I, ...args: any[])=>void;
declare type EachMapCallback<E extends any> = (key: string, entry: E)=>void;
declare type EachSetCallback<E extends any> = (entry: E, index: number)=>void;
I have noticed that for GameConfig declaration you are missing render property as the whole object also i am not sure if that property shouldn't be of type RendererConfig it has some similar properties like pixelArt, roundPixels, autoResize and some are on GameConfig like backgroundColor.
I have also noticed this one for optimization:
"render.powerPreference"?: string;
could be
"render.powerPreference"?: 'high-performance' | 'low-power' | 'default';
This one also seems to be wrong declare type ColorObject = ()=>void;