new Date(year, month) constructor documentation is misleading #49350
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
Bug Report
π Search Terms
date constructor month
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π 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:
month
parameter tomonthIndex
(MDN also usesmonthIndex
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#syntax)The text was updated successfully, but these errors were encountered: