You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hourCycle option not recognized for Date.toLocaleString #34399
test.ts:1:51 - error TS2345: Argument of type '{ hourCycle: string; }' is not assignable to parameter of type 'DateTimeFormatOptions'.
Object literal may only specify known properties, and 'hourCycle' does not exist in type 'DateTimeFormatOptions'.
1 const a = (new Date()).toLocaleString('en-US', {hourCycle: 'h24'});
~~~~~~~~~~~~~~~~
Found 1 error.
The generated code then runs fine under Node 12 (I think it's not supported below this version) and in browsers and prints the expected output of the date with requested hour cycle.
As of TypeScript 4.2 hourCycle is present on DateTimeFormatOptions - the interface used for the second parameter of toLocaleString - when you target es2020 or include it in your lib.
Activity
BPScott commentedon Aug 12, 2021
This issue can be closed.
As of TypeScript 4.2
hourCycleis present onDateTimeFormatOptions- the interface used for the second parameter oftoLocaleString- when you targetes2020or include it in your lib.This is a TS playground demonstrating that no errors occur if you target es2020