-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
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
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:
- rename
month
parameter tomonthIndex
(MDN also usesmonthIndex
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#syntax) - add JSDoc for the constructor explaining the month parameter
whzx5byb
Metadata
Metadata
Assignees
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript