Skip to content

Incorrect definition for Date.UTC #54084

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

Closed
tungs opened this issue May 1, 2023 · 2 comments · Fixed by #54125
Closed

Incorrect definition for Date.UTC #54084

tungs opened this issue May 1, 2023 · 2 comments · Fixed by #54125
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@tungs
Copy link

tungs commented May 1, 2023

es5.d.ts Update Request

Incorrect Definition

According to spec, the static method Date.UTC's second argument (monthIndex) should be optional, but in es5.d.ts, it isn't:

UTC(year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;

Sample Code

Date.UTC(2023); // should be valid

Documentation Links

MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#syntax
ECMAScript Spec: https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.utc

@Josh-Cena
Copy link
Contributor

Note that this is es5.d.ts, so it cannot encode ES2017+ semantics. However, I'm not sure if declaration merging allows overriding the optionality of parameters.

@fatcerberus
Copy link

Declaration merging creates overloads IIRC, so that should be allowed.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels May 2, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants