Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/lib/es2017.intl.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/es2021.intl.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 5 additions & 0 deletions tests/baselines/reference/formatToPartsFractionalSecond.js
Original file line number Diff line number Diff line change
@@ -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');
14 changes: 14 additions & 0 deletions tests/baselines/reference/formatToPartsFractionalSecond.symbols
Original file line number Diff line number Diff line change
@@ -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, --, --))

20 changes: 20 additions & 0 deletions tests/baselines/reference/formatToPartsFractionalSecond.types
Original file line number Diff line number Diff line change
@@ -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 : { <S extends Intl.DateTimeFormatPart>(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 : { <S extends Intl.DateTimeFormatPart>(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"

3 changes: 3 additions & 0 deletions tests/cases/compiler/formatToPartsFractionalSecond.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @target: esnext

new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond')