ui
ui copied to clipboard
types: Add generic types to Container-like views
Please Describe The Problem To Be Solved
It would be a nice addition if DisplayObjects were more type-friendly when it comes to handling children.
Pixi itself does that with Container
.
const container = new Container<Sprite>();
// Now I can manipulate children without casting type
(Optional): Suggest A Solution
Example using a List
const list = new List<Graphics>({
children: [
new Graphics().beginFill(0x000000).drawRect(0, 0, 50, 50),
new Graphics().beginFill(0xFFFFFF).drawRect(0, 0, 50, 50),
],
});
console.log(list.children); // Type of Graphics[]