Skip to content

Commit d080401

Browse files
committed
ScriptUI: Fix some incorrect typings
1 parent cf98d14 commit d080401

File tree

1 file changed

+23
-54
lines changed

1 file changed

+23
-54
lines changed

shared/ScriptUI.d.ts

Lines changed: 23 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ declare const enum _BrushOrPenType {
2121
THEME_COLOR,
2222
}
2323

24-
type _Bounds = Bounds | [number, number, number, number]
24+
type _Bounds = Bounds
2525

2626
/**
2727
* A global class containing central information about ScriptUI. Not instantiable.
@@ -159,12 +159,12 @@ declare class Window extends _Control {
159159
* The top left corner of the window frame in screen coordinates.
160160
* The same as [frameBounds.x, frameBounds.y]. Set this value to move the window frame to the specified location on the screen. The frameBounds value changes accordingly.
161161
*/
162-
frameLocation: Point | [number, number]
162+
frameLocation: Point
163163

164164
/**
165165
* The size and location of the window's frame in screen coordinates.
166166
*/
167-
readonly frameSize: Dimension | [number, number]
167+
readonly frameSize: Dimension
168168

169169
/**
170170
* Deprecated. Use ScriptUI.frameworkName instead.
@@ -484,7 +484,7 @@ declare class ScriptUIGraphics {
484484
/**
485485
* The current position in the current drawing path.
486486
*/
487-
readonly currentPoint: Point | [number, number]
487+
readonly currentPoint: Point
488488

489489
/**
490490
* The background color for containers when disabled or inactive; for non-containers, the parent background color.
@@ -558,7 +558,7 @@ declare class ScriptUIGraphics {
558558
* @param width The width of the region in pixels.
559559
* @param height The height of the region in pixels.
560560
*/
561-
ellipsePath(left: number, top: number, width: number, height: number): Point | [number, number]
561+
ellipsePath(left: number, top: number, width: number, height: number): Point
562562

563563
/**
564564
* Fills a path using a given painting brush.
@@ -573,7 +573,7 @@ declare class ScriptUIGraphics {
573573
* @param x The X coordinate for the destination point, relative to the origin of this element.
574574
* @param y The Y coordinate for the destination point, relative to the origin of this element.
575575
*/
576-
lineTo(x: number, y: number): Point | [number, number]
576+
lineTo(x: number, y: number): Point
577577

578578
/**
579579
* Calculates the size needed to display a string using the given font.
@@ -586,15 +586,15 @@ declare class ScriptUIGraphics {
586586
text: string,
587587
font?: ScriptUIFont,
588588
boundingWidth?: number,
589-
): Dimension | [number, number]
589+
): Dimension
590590

591591
/**
592592
* Adds a given point to the currentPath, and makes it the current drawing position.
593593
* Returns the Point object which is the new value of currentPoint.
594594
* @param x The X coordinate for the new point, relative to the origin of this element.
595595
* @param y The Y coordinate for the new point, relative to the origin of this element.
596596
*/
597-
moveTo(x: number, y: number): Point | [number, number]
597+
moveTo(x: number, y: number): Point
598598

599599
/**
600600
* Creates a new painting brush object.
@@ -625,7 +625,7 @@ declare class ScriptUIGraphics {
625625
* @param width The width in pixels.
626626
* @param height The height in pixels.
627627
*/
628-
rectPath(left: number, top: number, width: number, height: number): Point | [number, number]
628+
rectPath(left: number, top: number, width: number, height: number): Point
629629

630630
/**
631631
* Strokes the path segments of a path with a given drawing pen.
@@ -755,7 +755,7 @@ declare class ScriptUIImage {
755755
/**
756756
* The image size in pixels.
757757
*/
758-
readonly size: Dimension | [number, number]
758+
readonly size: Dimension
759759
}
760760

761761
/**
@@ -1149,7 +1149,7 @@ declare class ListBox extends _Control {
11491149
* The width and height in pixels of each item in the list.
11501150
* Used by auto-layout to determine the preferredSize of the list, if not otherwise specified. If not set explicitly, the size of each item is set to match the largest height and width among all items in the list
11511151
*/
1152-
itemSize: Dimension | [number, number]
1152+
itemSize: Dimension
11531153

11541154
/**
11551155
* The array of choice items displayed in the list.
@@ -1262,7 +1262,7 @@ declare class DropDownList extends _Control {
12621262
* The width and height in pixels of each item in the list.
12631263
* Used by auto-layout to determine the preferredSize of the list, if not otherwise specified. If not set explicitly, the size of each item is set to match the largest height and width among all items in the list
12641264
*/
1265-
itemSize: Dimension | [number, number]
1265+
itemSize: Dimension
12661266

12671267
/**
12681268
* The array of choice items displayed in the drop-down or pop-up list.
@@ -1816,7 +1816,7 @@ declare class TreeView extends _Control {
18161816
* The width and height in pixels of each item in the list.
18171817
* Used by auto-layout to determine the preferredSize of the list, if not otherwise specified. If not set explicitly, the size of each item is set to match the largest height and width among all items in the list
18181818
*/
1819-
itemSize: Dimension | [number, number]
1819+
itemSize: Dimension
18201820

18211821
/**
18221822
* The array of top-level items displayed in the list.
@@ -1968,7 +1968,7 @@ declare class Group extends _Control {
19681968
* Tells the layout manager how unlike-sized children of this container should be aligned within a column or row.
19691969
* Order of creation determines which children are at the top of a column or the left of a row; the earlier a child is created, the closer it is to the top or left of its column or row. If defined, alignment for a child element overrides the alignChildren setting for the parent container. See alignment property for values.
19701970
*/
1971-
alignChildren: string
1971+
alignChildren: string | string[]
19721972

19731973
/**
19741974
* An array of child elements.
@@ -2154,17 +2154,12 @@ declare class TabbedPanel extends Panel {
21542154
* Specifies the origin point of an element as horizontal and vertical pixel offsets from the origin of the element's coordinate space.
21552155
* A Point object is created when you set an element’s location property. You can set the property using a JavaScript object with properties named x and y, or an array with 2 values in the order [x, y].
21562156
*/
2157-
declare class Point {
2157+
declare class Point extends Array<number> {
21582158
/**
21592159
* The left coordinate.
21602160
*/
21612161
left: number
21622162

2163-
/**
2164-
* The array length.
2165-
*/
2166-
readonly length: number
2167-
21682163
/**
21692164
* The top coordinate.
21702165
*/
@@ -2179,42 +2174,29 @@ declare class Point {
21792174
* The vertical coordinate, a pixel offset from the origin of the element's coordinate space.
21802175
*/
21812176
y: number;
2182-
2183-
[0]: number;
2184-
2185-
[1]: number
21862177
}
21872178

21882179
/**
21892180
* Defines the size of a window or UI element. Contains a 2-element array.
21902181
* Specifies the height and width of an element in pixels. A Dimension object is created when you set an element’s size property. You can set the property using a JavaScript object with named properties {width: wd, height: ht}, or an array with 2 values in the order [wd, ht].
21912182
*/
2192-
declare class Dimension {
2183+
declare class Dimension extends Array<number> {
21932184
/**
21942185
* The height in pixels.
21952186
*/
21962187
height: number
21972188

2198-
/**
2199-
* The array length.
2200-
*/
2201-
readonly length: number
2202-
22032189
/**
22042190
* The width in pixels.
22052191
*/
22062192
width: number;
2207-
2208-
[0]: number;
2209-
2210-
[1]: number
22112193
}
22122194

22132195
/**
22142196
* Defines the boundaries of a window within the screen’s coordinate space, or of a UI element within the container’s coordinate space.
22152197
* A Bounds object is created when you set an element’s bounds property. You can set the property using a JavaScript object with properties named left, top, right, bottom or x, y, width, height, or an array with 4 values in the order [x, y, wd, ht].
22162198
*/
2217-
declare class Bounds {
2199+
declare class Bounds extends Array<number> {
22182200
/**
22192201
* The vertical coordinate, a pixel offset from the origin of the element's coordinate space.
22202202
*/
@@ -2230,11 +2212,6 @@ declare class Bounds {
22302212
*/
22312213
left: number
22322214

2233-
/**
2234-
* The array length.
2235-
*/
2236-
readonly length: number
2237-
22382215
/**
22392216
* The width in pixels.
22402217
*/
@@ -2259,14 +2236,6 @@ declare class Bounds {
22592236
* The vertical coordinate, a pixel offset from the origin of the element's coordinate space.
22602237
*/
22612238
y: number;
2262-
2263-
[0]: number;
2264-
2265-
[1]: number;
2266-
2267-
[2]: number;
2268-
2269-
[3]: number
22702239
}
22712240

22722241
/**
@@ -2520,7 +2489,7 @@ declare class _Control {
25202489
* For orientation = column: left, right, fill
25212490
* For orientation = stack: top, bottom, left, right, fill
25222491
*/
2523-
alignment: string
2492+
alignment: string | string[]
25242493

25252494
/**
25262495
* The boundaries of the element, in parent-relative coordinates.
@@ -2549,17 +2518,17 @@ declare class _Control {
25492518
* The upper left corner of this element relative to its parent.
25502519
* The location is defined as [bounds.x, bounds.y]. Setting an element's location changes its bounds property, and vice-versa.
25512520
*/
2552-
location: Point | [number, number]
2521+
location: Point
25532522

25542523
/**
25552524
* The maximum height and width to which the element can be resized.
25562525
*/
2557-
maximumSize: Dimension | [number, number]
2526+
maximumSize: Dimension
25582527

25592528
/**
25602529
* The minimum height and width to which the element can be resized.
25612530
*/
2562-
minimumSize: Dimension | [number, number]
2531+
minimumSize: Dimension
25632532

25642533
/**
25652534
* The parent element.
@@ -2571,13 +2540,13 @@ declare class _Control {
25712540
* If not explicitly set by a script, value is established by the UI framework in which ScriptUI is employed, and is based on such attributes of the element as its text, font, font size, icon size, and other UI framework-specific attributes. A script can explicitly set this value before the layout manager is invoked in order to establish an element size other than the default.
25722541
* To set a specific value for only one dimension, specify the other dimension as -1.
25732542
*/
2574-
preferredSize: Dimension | [number, number]
2543+
preferredSize: Dimension
25752544

25762545
/**
25772546
* The current dimensions of this element.
25782547
* Initially undefined, and unless explicitly set by a script, it is defined by a LayoutManager . A script can explicitly set size before the layout manager is invoked to establish an element size other than the preferredSize or the default size, but this is not recommended. Defined as [bounds.width, bounds.height]. Setting an element's size changes its bounds property, and vice-versa.
25792548
*/
2580-
size: Dimension | [number, number]
2549+
size: Dimension
25812550

25822551
/**
25832552
* The element type.

0 commit comments

Comments
 (0)