Skip to content

Commit 7b9ceb8

Browse files
alan-agius4mhegazy
authored andcommitted
refactor: use union type in DateConstructor (microsoft#21757)
* refactor: use union type in `DateConstructor` Add support for union types in `DateConstructor` This will add support for something like the below; ` let date; string | number; const date = new Date(x); ` Closes: microsoft#21758 * fix: date constructor can't be passed `string | Date`, but takes either individually Closes: microsoft#20900
1 parent 5915b6d commit 7b9ceb8

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/lib.es5.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,7 @@ interface Date {
792792

793793
interface DateConstructor {
794794
new(): Date;
795-
new(value: number): Date;
796-
new(value: string): Date;
795+
new(value: string | number): Date;
797796
new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;
798797
(): string;
799798
readonly prototype: Date;

src/lib/es2015.core.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ interface ArrayConstructor {
6969
}
7070

7171
interface DateConstructor {
72-
new (value: Date): Date;
72+
new (value: number | string | Date): Date;
7373
}
7474

7575
interface Function {

0 commit comments

Comments
 (0)