export type PlaceableBBox = { x?: number; y?: number; width: number; height: number; }; export class Placeable { public bbox!: BBoxType; private _place: Placeable['place']; public place(point: { x: number }): this is Placeable; public place(point: { y: number }): this is Placeable; public place(point: { x: number; y: number }): this is Placeable { return this._place(point); } // assumes the first BBoxType is always just width and height constructor(width: number, height: number, place: Placeable['place']) { this.bbox = { width, height } as BBoxType; this._place = place; } public get x(): BBoxType['x'] { return this.bbox.x; } public get y(): BBoxType['y'] { return this.bbox.y; } public get width(): number { return this.bbox.width; } public get height(): number { return this.bbox.height; } }