Adds VarDate and SafeArray<T> as pseudonominal types to lib.d.ts (#18566)

* SafeArray<T>; stronger typing for VarDate, and for VBArray and Enumerator constructors

* Add overload to Enumerator based on Item method

* Add return type to Enumerator constructor
This commit is contained in:
Zev Spitz 2017-09-20 03:04:50 +03:00 committed by Mohamed Hegazy
parent b549e26665
commit 8245597bfe

View File

@ -201,10 +201,18 @@ declare var WScript: {
Sleep(intTime: number): void;
};
/**
* Represents an Automation SAFEARRAY
*/
declare class SafeArray<T = any> {
private constructor();
private SafeArray_typekey: SafeArray<T>;
}
/**
* Allows enumerating over a COM collection, which may not have indexed item access.
*/
interface Enumerator<T> {
interface Enumerator<T = any> {
/**
* 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,9 @@ interface Enumerator<T> {
}
interface EnumeratorConstructor {
new <T>(collection: any): Enumerator<T>;
new (collection: any): Enumerator<any>;
new <T = any>(safearray: SafeArray<T>): Enumerator<T>;
new <T = any>(collection: { Item(index: any): T }): Enumerator<T>;
new <T = any>(collection: any): Enumerator<T>;
}
declare var Enumerator: EnumeratorConstructor;
@ -239,7 +248,7 @@ declare var Enumerator: EnumeratorConstructor;
/**
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
*/
interface VBArray<T> {
interface VBArray<T = any> {
/**
* Returns the number of dimensions (1-based).
*/
@ -271,8 +280,7 @@ interface VBArray<T> {
}
interface VBArrayConstructor {
new <T>(safeArray: any): VBArray<T>;
new (safeArray: any): VBArray<any>;
new <T = any>(safeArray: SafeArray<T>): VBArray<T>;
}
declare var VBArray: VBArrayConstructor;
@ -280,7 +288,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;