mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
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
This commit is contained in:
parent
5915b6d3aa
commit
7b9ceb85fa
3
lib/lib.es5.d.ts
vendored
3
lib/lib.es5.d.ts
vendored
@ -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;
|
||||
|
||||
2
src/lib/es2015.core.d.ts
vendored
2
src/lib/es2015.core.d.ts
vendored
@ -69,7 +69,7 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
interface DateConstructor {
|
||||
new (value: Date): Date;
|
||||
new (value: number | string | Date): Date;
|
||||
}
|
||||
|
||||
interface Function {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user