From 7326e8c5771a39093c8e907c7ad8db98dfd1cf99 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Mon, 11 Sep 2017 16:32:11 +0200 Subject: [PATCH 1/3] SafeArray; stronger typing for VarDate, and for VBArray and Enumerator constructors --- src/lib/scripthost.d.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index bec8be3173506..ce50e4912f039 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -201,10 +201,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -230,8 +238,8 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -239,7 +247,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -271,8 +279,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -280,7 +287,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; From c20c82c956990e2ebb518e44527ca8f2cb374879 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Tue, 19 Sep 2017 09:08:18 +0200 Subject: [PATCH 2/3] Add overload to Enumerator based on Item method --- src/lib/scripthost.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index ce50e4912f039..ed745cede96d9 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -239,6 +239,7 @@ interface Enumerator { interface EnumeratorConstructor { new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }); new (collection: any): Enumerator; } From 6d4c32c02f6eb2f3d13aa510ad88ff5020f4f17f Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Tue, 19 Sep 2017 10:31:41 +0200 Subject: [PATCH 3/3] Add return type to Enumerator constructor --- src/lib/scripthost.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index ed745cede96d9..1fbd185949f26 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -239,7 +239,7 @@ interface Enumerator { interface EnumeratorConstructor { new (safearray: SafeArray): Enumerator; - new (collection: { Item(index: any): T }); + new (collection: { Item(index: any): T }): Enumerator; new (collection: any): Enumerator; }