diff --git a/src/lib/es2017.intl.d.ts b/src/lib/es2017.intl.d.ts index 6f6495da022..2f9efc15fbb 100644 --- a/src/lib/es2017.intl.d.ts +++ b/src/lib/es2017.intl.d.ts @@ -1,5 +1,20 @@ declare namespace Intl { - type DateTimeFormatPartTypes = "day" | "dayPeriod" | "era" | "hour" | "literal" | "minute" | "month" | "second" | "timeZoneName" | "weekday" | "year"; + + interface DateTimeFormatPartTypesRegistry { + day: any + dayPeriod: any + era: any + hour: any + literal: any + minute: any + month: any + second: any + timeZoneName: any + weekday: any + year: any + } + + type DateTimeFormatPartTypes = keyof DateTimeFormatPartTypesRegistry; interface DateTimeFormatPart { type: DateTimeFormatPartTypes; diff --git a/src/lib/es2021.intl.d.ts b/src/lib/es2021.intl.d.ts index 2424dc404a1..9de1a9a2036 100644 --- a/src/lib/es2021.intl.d.ts +++ b/src/lib/es2021.intl.d.ts @@ -1,5 +1,9 @@ declare namespace Intl { + interface DateTimeFormatPartTypesRegistry { + fractionalSecond: any + } + interface DateTimeFormatOptions { formatMatcher?: "basic" | "best fit" | "best fit" | undefined; dateStyle?: "full" | "long" | "medium" | "short" | undefined; diff --git a/tests/baselines/reference/formatToPartsFractionalSecond.js b/tests/baselines/reference/formatToPartsFractionalSecond.js new file mode 100644 index 00000000000..5f91647a5e7 --- /dev/null +++ b/tests/baselines/reference/formatToPartsFractionalSecond.js @@ -0,0 +1,5 @@ +//// [formatToPartsFractionalSecond.ts] +new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond') + +//// [formatToPartsFractionalSecond.js] +new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond'); diff --git a/tests/baselines/reference/formatToPartsFractionalSecond.symbols b/tests/baselines/reference/formatToPartsFractionalSecond.symbols new file mode 100644 index 00000000000..01a0ff9b48d --- /dev/null +++ b/tests/baselines/reference/formatToPartsFractionalSecond.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/formatToPartsFractionalSecond.ts === +new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond') +>new Intl.DateTimeFormat().formatToParts().find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>new Intl.DateTimeFormat().formatToParts : Symbol(Intl.DateTimeFormat.formatToParts, Decl(lib.es2017.intl.d.ts, --, --)) +>Intl.DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 3 more) +>DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) +>formatToParts : Symbol(Intl.DateTimeFormat.formatToParts, Decl(lib.es2017.intl.d.ts, --, --)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(formatToPartsFractionalSecond.ts, 0, 48)) +>val.type : Symbol(Intl.DateTimeFormatPart.type, Decl(lib.es2017.intl.d.ts, --, --)) +>val : Symbol(val, Decl(formatToPartsFractionalSecond.ts, 0, 48)) +>type : Symbol(Intl.DateTimeFormatPart.type, Decl(lib.es2017.intl.d.ts, --, --)) + diff --git a/tests/baselines/reference/formatToPartsFractionalSecond.types b/tests/baselines/reference/formatToPartsFractionalSecond.types new file mode 100644 index 00000000000..222c94fd832 --- /dev/null +++ b/tests/baselines/reference/formatToPartsFractionalSecond.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/formatToPartsFractionalSecond.ts === +new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond') +>new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond') : Intl.DateTimeFormatPart +>new Intl.DateTimeFormat().formatToParts().find : { (predicate: (this: void, value: Intl.DateTimeFormatPart, index: number, obj: Intl.DateTimeFormatPart[]) => value is S, thisArg?: any): S; (predicate: (value: Intl.DateTimeFormatPart, index: number, obj: Intl.DateTimeFormatPart[]) => unknown, thisArg?: any): Intl.DateTimeFormatPart; } +>new Intl.DateTimeFormat().formatToParts() : Intl.DateTimeFormatPart[] +>new Intl.DateTimeFormat().formatToParts : (date?: number | Date) => Intl.DateTimeFormatPart[] +>new Intl.DateTimeFormat() : Intl.DateTimeFormat +>Intl.DateTimeFormat : { (locales?: string | string[], options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat; new (locales?: string | string[], options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: Intl.DateTimeFormatOptions): string[]; readonly prototype: Intl.DateTimeFormat; } +>Intl : typeof Intl +>DateTimeFormat : { (locales?: string | string[], options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat; new (locales?: string | string[], options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: Intl.DateTimeFormatOptions): string[]; readonly prototype: Intl.DateTimeFormat; } +>formatToParts : (date?: number | Date) => Intl.DateTimeFormatPart[] +>find : { (predicate: (this: void, value: Intl.DateTimeFormatPart, index: number, obj: Intl.DateTimeFormatPart[]) => value is S, thisArg?: any): S; (predicate: (value: Intl.DateTimeFormatPart, index: number, obj: Intl.DateTimeFormatPart[]) => unknown, thisArg?: any): Intl.DateTimeFormatPart; } +>(val) => val.type === 'fractionalSecond' : (this: void, val: Intl.DateTimeFormatPart) => boolean +>val : Intl.DateTimeFormatPart +>val.type === 'fractionalSecond' : boolean +>val.type : keyof Intl.DateTimeFormatPartTypesRegistry +>val : Intl.DateTimeFormatPart +>type : keyof Intl.DateTimeFormatPartTypesRegistry +>'fractionalSecond' : "fractionalSecond" + diff --git a/tests/cases/compiler/formatToPartsFractionalSecond.ts b/tests/cases/compiler/formatToPartsFractionalSecond.ts new file mode 100644 index 00000000000..9b296d4a657 --- /dev/null +++ b/tests/cases/compiler/formatToPartsFractionalSecond.ts @@ -0,0 +1,3 @@ +// @target: esnext + +new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond') \ No newline at end of file