Skip to content

Type definition for fractionalSecondDigits in Intl.DateTimeFormatOptions has incorrect 0. #48912

@mstssk

Description

@mstssk

lib Update Request

Configuration Check

My compilation target is es2016 and my lib is es2021.

Missing / Incorrect Definition

fractionalSecondDigits in Intl.DateTimeFormatOptions should not have 0.
However current type definition is fractionalSecondDigits?: 0 | 1 | 2 | 3 | undefined;.
https://github.com/microsoft/TypeScript/blob/v4.6.4/src/lib/es2021.intl.d.ts

Sample Code

Intl.DateTimeFormat("en-US", { fractionalSecondDigits: 0 });
// RangeError: fractionalSecondDigits value is out of range.

This code throws RangeError on Chrome v101, Safari v15.4, Firefox v99 and Node.js v16,v17.

Documentation Link

fractionalSecondDigits values are 1, 2 or 3 in ECMAScript® 2021 Internationalization API Specification.
https://402.ecma-international.org/8.0/#sec-datetimeformat-abstracts

Related conversation at tc39/ecma402#590

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do thislib updatePR modifies files in the `lib` folder

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions