Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/lib/scripthost.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -230,16 +238,17 @@ 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;

/**
* 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).
*/
Expand Down Expand Up @@ -271,16 +280,18 @@ 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;

/**
* Automation date (VT_DATE)
*/
interface VarDate { }
declare class VarDate {
private constructor();
private VarDate_typekey: VarDate;
}

interface DateConstructor {
new (vd: VarDate): Date;
Expand Down