From 7b9ceb85fa4e19ade740faa2af2e00e62e16f7c9 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 8 Feb 2018 21:22:37 +0100 Subject: [PATCH] refactor: use union type in `DateConstructor` (#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: #21758 * fix: date constructor can't be passed `string | Date`, but takes either individually Closes: #20900 --- lib/lib.es5.d.ts | 3 +-- src/lib/es2015.core.d.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 3f495ed40a9..07ffe74c05f 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -792,8 +792,7 @@ interface Date { interface DateConstructor { new(): Date; - new(value: number): Date; - new(value: string): Date; + new(value: string | number): Date; new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; (): string; readonly prototype: Date; diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index eef20591a84..68be040c29d 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -69,7 +69,7 @@ interface ArrayConstructor { } interface DateConstructor { - new (value: Date): Date; + new (value: number | string | Date): Date; } interface Function {