Skip to content

new Date(year, month) constructor documentation is misleading #49350

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
Yonom opened this issue Jun 2, 2022 · 0 comments Β· Fixed by #49649
Closed

new Date(year, month) constructor documentation is misleading #49350

Yonom opened this issue Jun 2, 2022 · 0 comments Β· Fixed by #49649
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@Yonom
Copy link

Yonom commented Jun 2, 2022

Bug Report

πŸ”Ž Search Terms

date constructor month

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about naming conventions

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

// this is May 2022
new Date(2022, 4)

πŸ™ Actual behavior

image

The date constructor documentation gives no indication that the month parameter is zero index based (January is month 0, February is month 1). This can cause off-by-one error bugs that are hard to detect.

πŸ™‚ Expected behavior

I expected the documentation to be clear about the type of value expected in the constructor. For example:

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Experience Enhancement Noncontroversial enhancements labels Jun 2, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 2, 2022
mkubilayk pushed a commit to bloomberg/TypeScript that referenced this issue Jun 22, 2022
) (#73)

* Update month parameter to monthIndex and add docs for Date constructor

Signed-off-by: jmorrison152 <[email protected]>

* Add baseline changes

Signed-off-by: jmorrison152 <[email protected]>
clarfonthey pushed a commit to clarfonthey/TypeScript that referenced this issue Aug 9, 2022
) (microsoft#49649)

* Update month parameter to monthIndex and add docs for Date constructor

Signed-off-by: jmorrison152 <[email protected]>

* Add baseline changes

Signed-off-by: jmorrison152 <[email protected]>

* Fix misleading Date constructor documentation (addresses microsoft#49350) (microsoft#73)

* Update month parameter to monthIndex and add docs for Date constructor

Signed-off-by: jmorrison152 <[email protected]>

* Add baseline changes

Signed-off-by: jmorrison152 <[email protected]>

* Update baselines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants