Skip to content

Commit 7326e8c

Browse files
committed
SafeArray<T>; stronger typing for VarDate, and for VBArray and Enumerator constructors
1 parent ab2e2cf commit 7326e8c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/lib/scripthost.d.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,18 @@ declare var WScript: {
201201
Sleep(intTime: number): void;
202202
};
203203

204+
/**
205+
* Represents an Automation SAFEARRAY
206+
*/
207+
declare class SafeArray<T = any> {
208+
private constructor();
209+
private SafeArray_typekey: SafeArray<T>;
210+
}
211+
204212
/**
205213
* Allows enumerating over a COM collection, which may not have indexed item access.
206214
*/
207-
interface Enumerator<T> {
215+
interface Enumerator<T = any> {
208216
/**
209217
* Returns true if the current item is the last one in the collection, or the collection is empty,
210218
* or the current item is undefined.
@@ -230,16 +238,16 @@ interface Enumerator<T> {
230238
}
231239

232240
interface EnumeratorConstructor {
233-
new <T>(collection: any): Enumerator<T>;
234-
new (collection: any): Enumerator<any>;
241+
new <T = any>(safearray: SafeArray<T>): Enumerator<T>;
242+
new <T = any>(collection: any): Enumerator<T>;
235243
}
236244

237245
declare var Enumerator: EnumeratorConstructor;
238246

239247
/**
240248
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
241249
*/
242-
interface VBArray<T> {
250+
interface VBArray<T = any> {
243251
/**
244252
* Returns the number of dimensions (1-based).
245253
*/
@@ -271,16 +279,18 @@ interface VBArray<T> {
271279
}
272280

273281
interface VBArrayConstructor {
274-
new <T>(safeArray: any): VBArray<T>;
275-
new (safeArray: any): VBArray<any>;
282+
new <T = any>(safeArray: SafeArray<T>): VBArray<T>;
276283
}
277284

278285
declare var VBArray: VBArrayConstructor;
279286

280287
/**
281288
* Automation date (VT_DATE)
282289
*/
283-
interface VarDate { }
290+
declare class VarDate {
291+
private constructor();
292+
private VarDate_typekey: VarDate;
293+
}
284294

285295
interface DateConstructor {
286296
new (vd: VarDate): Date;

0 commit comments

Comments
 (0)