-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Closed
Copy link
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx)
Automation host objects pass dates into Javascript as VarDate
per the specification (copy found here) (section 2.2.2). These need to be wrapped in a Date
constructor before they can be used in Javascript.
Such properties therefore cannot be typed as Date
in declarations.
Code
namespace Scripting {
interface File {
DateCreated: Date;
}
interface FileSystemObject {
GetFile(FilePath: string): File
}
}
interface ActiveXObject {
new (s: 'Scripting.FileSystemObject'): Scripting.FileSystemObject;
}
// Under WSH
var fso = new ActiveXObject('Scripting.FileSystemObject');
var file = fso.GetFile('C:\\test.txt');
var varDate = file.DateCreated;
//the following fails with "'varDate' is null or not an object"
//WScript.Echo(varDate.getYear());
//outputs the year
WScript.Echo(new Date(varDate).getYear());
Proposal
Add the following to scripthost.d.ts:
interface VarDate { }
interface DateConstructor {
new (vd: VarDate): Date;
getVarDate: () => VarDate;
}
and such date properties could use VarDate
instead of Date
.
Metadata
Metadata
Assignees
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript