Skip to content

Missing specific types in DateTimeFormatOptions #35865

Closed
@ksoldau

Description

@ksoldau

TypeScript Version: 3.7.3

Search Terms: Intl.DateTimeFormat, DateTimeFormatOptions, date format types

Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp,
(See below)

DateTimeFormatOptions interface missing specific types.

TypeScript/src/lib/es5.d.ts

Lines 4253 to 4267 in 408b176

interface DateTimeFormatOptions {
localeMatcher?: string;
weekday?: string;
era?: string;
year?: string;
month?: string;
day?: string;
hour?: string;
minute?: string;
second?: string;
timeZoneName?: string;
formatMatcher?: string;
hour12?: boolean;
timeZone?: string;
}

Expected behavior:
I would expect the types to match what's listed here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat

  interface DateTimeFormatOptions {
        localeMatcher?: 'lookup' | 'best fit';
        weekday?: 'long' | 'short' | 'narrow';
        era?:  'long' | 'short' | 'narrow';
        year?: 'numeric' | '2-digit';
        month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
        day?: 'numeric' | '2-digit';
        hour?: 'numeric' | '2-digit';
        minute?: 'numeric' | '2-digit';
        second?: 'numeric' | '2-digit';
        timeZoneName?: 'long' | 'short';
        formatMatcher?: 'basic' | 'best fit';
        hour12?: boolean;
        timeZone?: string; // this is more complicated than the others, not sure what I expect here
    }

Actual behavior:

 interface DateTimeFormatOptions {
        localeMatcher?: string;
        weekday?: string;
        era?: string;
        year?: string;
        month?: string;
        day?: string;
        hour?: string;
        minute?: string;
        second?: string;
        timeZoneName?: string;
        formatMatcher?: string;
        hour12?: boolean;
        timeZone?: string;
    }

Playground Link:

Related Issues:
Couldn't find any

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions