screepers / Screeps-Typescript-Declarations

The repository for *Screeps's* TypeScript type definitions.
69 stars 44 forks source link

Update RoomVisual.poly to also accept positions #113

Open Dessix opened 7 years ago

Dessix commented 7 years ago

From the documentation:

points | array | An array of points.
Every item should be either an array with 2 numbers (i.e. [10,15]), or a RoomPosition object.
Dessix commented 7 years ago

The changes I've pushed allow objects meeting the { x: number, y: number } structural interface to be used in place of RoomPosition instances. I've tested these as working. This also changes RoomVisual's constructor to the Typescript standard es6 declaration style, wherein the constructor and instance types are separate interfaces, and provides separate subtypes for differentiating the availability of roomName depending on whether or not the "global" constructor was used.

thaelina commented 7 years ago

I tested these changes and was unable to declare a RoomVisual Error:(39, 19) TS2693:'RoomVisual' only refers to a type, but is being used as a value here. let vis = new RoomVisual();

Need to add declare const RoomVisual: RoomVisualConstructor;

I know this has been languishing here, but hopefully we can get this repo updated and such

Dessix commented 7 years ago

Added constructor object instance for RoomVisual as per @thaelina's suggestion and rebuilt.