Skip to content

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

Closed
@Yonom

Description

@Yonom

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptExperience EnhancementNoncontroversial enhancementsHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions