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
10 changes: 9 additions & 1 deletion src/lib/es2023.intl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ declare namespace Intl {
negative: never;
}

interface NumberFormatRangePartTypeRegistry extends NumberFormatPartTypeRegistry {
approximatelySign: never;
}

type NumberFormatRangePartTypes = keyof NumberFormatRangePartTypeRegistry;

interface NumberFormatOptions {
roundingPriority?: "auto" | "morePrecision" | "lessPrecision" | undefined;
roundingIncrement?: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000 | undefined;
Expand All @@ -23,7 +29,9 @@ declare namespace Intl {
trailingZeroDisplay: "auto" | "stripIfInteger";
}

interface NumberRangeFormatPart extends NumberFormatPart {
interface NumberRangeFormatPart {
type: NumberFormatRangePartTypes;
value: string;
source: "startRange" | "endRange" | "shared";
}

Expand Down
24 changes: 24 additions & 0 deletions tests/baselines/reference/intlNumberFormatES2023.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8');
new Intl.NumberFormat('en-GB').format('Infinity');
new Intl.NumberFormat('en-GB').format('-Infinity');
new Intl.NumberFormat('en-GB').format('+Infinity');

// Test approximatelySign part type
const nf = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "EUR",
maximumFractionDigits: 0,
});

const filtered = nf
.formatRangeToParts(100, 100)
.filter((part) => part.type !== "approximatelySign")
.map((part) => part.value)
.join("");


//// [intlNumberFormatES2023.js]
Expand Down Expand Up @@ -59,3 +72,14 @@ new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8');
new Intl.NumberFormat('en-GB').format('Infinity');
new Intl.NumberFormat('en-GB').format('-Infinity');
new Intl.NumberFormat('en-GB').format('+Infinity');
// Test approximatelySign part type
const nf = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "EUR",
maximumFractionDigits: 0,
});
const filtered = nf
.formatRangeToParts(100, 100)
.filter((part) => part.type !== "approximatelySign")
.map((part) => part.value)
.join("");
46 changes: 46 additions & 0 deletions tests/baselines/reference/intlNumberFormatES2023.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,49 @@ new Intl.NumberFormat('en-GB').format('+Infinity');
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
>format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))

// Test approximatelySign part type
const nf = new Intl.NumberFormat("en-US", {
>nf : Symbol(nf, Decl(intlNumberFormatES2023.ts, 32, 5))
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2016.intl.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2019.intl.d.ts, --, --) ... and 5 more)
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))

style: "currency",
>style : Symbol(style, Decl(intlNumberFormatES2023.ts, 32, 43))

currency: "EUR",
>currency : Symbol(currency, Decl(intlNumberFormatES2023.ts, 33, 20))

maximumFractionDigits: 0,
>maximumFractionDigits : Symbol(maximumFractionDigits, Decl(intlNumberFormatES2023.ts, 34, 18))

});

const filtered = nf
>filtered : Symbol(filtered, Decl(intlNumberFormatES2023.ts, 38, 5))
>nf .formatRangeToParts(100, 100) .filter((part) => part.type !== "approximatelySign") .map((part) => part.value) .join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --))
>nf .formatRangeToParts(100, 100) .filter((part) => part.type !== "approximatelySign") .map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>nf .formatRangeToParts(100, 100) .filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>nf .formatRangeToParts : Symbol(Intl.NumberFormat.formatRangeToParts, Decl(lib.es2023.intl.d.ts, --, --))
>nf : Symbol(nf, Decl(intlNumberFormatES2023.ts, 32, 5))

.formatRangeToParts(100, 100)
>formatRangeToParts : Symbol(Intl.NumberFormat.formatRangeToParts, Decl(lib.es2023.intl.d.ts, --, --))

.filter((part) => part.type !== "approximatelySign")
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>part : Symbol(part, Decl(intlNumberFormatES2023.ts, 40, 11))
>part.type : Symbol(Intl.NumberRangeFormatPart.type, Decl(lib.es2023.intl.d.ts, --, --))
>part : Symbol(part, Decl(intlNumberFormatES2023.ts, 40, 11))
>type : Symbol(Intl.NumberRangeFormatPart.type, Decl(lib.es2023.intl.d.ts, --, --))

.map((part) => part.value)
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>part : Symbol(part, Decl(intlNumberFormatES2023.ts, 41, 8))
>part.value : Symbol(Intl.NumberRangeFormatPart.value, Decl(lib.es2023.intl.d.ts, --, --))
>part : Symbol(part, Decl(intlNumberFormatES2023.ts, 41, 8))
>value : Symbol(Intl.NumberRangeFormatPart.value, Decl(lib.es2023.intl.d.ts, --, --))

.join("");
>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --))

105 changes: 105 additions & 0 deletions tests/baselines/reference/intlNumberFormatES2023.types
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,108 @@ new Intl.NumberFormat('en-GB').format('+Infinity');
>'+Infinity' : "+Infinity"
> : ^^^^^^^^^^^

// Test approximatelySign part type
const nf = new Intl.NumberFormat("en-US", {
>nf : Intl.NumberFormat
> : ^^^^^^^^^^^^^^^^^
>new Intl.NumberFormat("en-US", { style: "currency", currency: "EUR", maximumFractionDigits: 0,}) : Intl.NumberFormat
> : ^^^^^^^^^^^^^^^^^
>Intl.NumberFormat : Intl.NumberFormatConstructor
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>Intl : typeof Intl
> : ^^^^^^^^^^^
>NumberFormat : Intl.NumberFormatConstructor
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>"en-US" : "en-US"
> : ^^^^^^^
>{ style: "currency", currency: "EUR", maximumFractionDigits: 0,} : { style: "currency"; currency: string; maximumFractionDigits: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

style: "currency",
>style : "currency"
> : ^^^^^^^^^^
>"currency" : "currency"
> : ^^^^^^^^^^

currency: "EUR",
>currency : string
> : ^^^^^^
>"EUR" : "EUR"
> : ^^^^^

maximumFractionDigits: 0,
>maximumFractionDigits : number
> : ^^^^^^
>0 : 0
> : ^

});

const filtered = nf
>filtered : string
> : ^^^^^^
>nf .formatRangeToParts(100, 100) .filter((part) => part.type !== "approximatelySign") .map((part) => part.value) .join("") : string
> : ^^^^^^
>nf .formatRangeToParts(100, 100) .filter((part) => part.type !== "approximatelySign") .map((part) => part.value) .join : (separator?: string) => string
> : ^ ^^^ ^^^^^
>nf .formatRangeToParts(100, 100) .filter((part) => part.type !== "approximatelySign") .map((part) => part.value) : string[]
> : ^^^^^^^^
>nf .formatRangeToParts(100, 100) .filter((part) => part.type !== "approximatelySign") .map : <U>(callbackfn: (value: Intl.NumberRangeFormatPart, index: number, array: Intl.NumberRangeFormatPart[]) => U, thisArg?: any) => U[]
> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^
>nf .formatRangeToParts(100, 100) .filter((part) => part.type !== "approximatelySign") : Intl.NumberRangeFormatPart[]
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>nf .formatRangeToParts(100, 100) .filter : { <S extends Intl.NumberRangeFormatPart>(predicate: (value: Intl.NumberRangeFormatPart, index: number, array: Intl.NumberRangeFormatPart[]) => value is S, thisArg?: any): S[]; (predicate: (value: Intl.NumberRangeFormatPart, index: number, array: Intl.NumberRangeFormatPart[]) => unknown, thisArg?: any): Intl.NumberRangeFormatPart[]; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>nf .formatRangeToParts(100, 100) : Intl.NumberRangeFormatPart[]
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>nf .formatRangeToParts : (start: number | bigint | Intl.StringNumericLiteral, end: number | bigint | Intl.StringNumericLiteral) => Intl.NumberRangeFormatPart[]
> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>nf : Intl.NumberFormat
> : ^^^^^^^^^^^^^^^^^

.formatRangeToParts(100, 100)
>formatRangeToParts : (start: number | bigint | Intl.StringNumericLiteral, end: number | bigint | Intl.StringNumericLiteral) => Intl.NumberRangeFormatPart[]
> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>100 : 100
> : ^^^
>100 : 100
> : ^^^

.filter((part) => part.type !== "approximatelySign")
>filter : { <S extends Intl.NumberRangeFormatPart>(predicate: (value: Intl.NumberRangeFormatPart, index: number, array: Intl.NumberRangeFormatPart[]) => value is S, thisArg?: any): S[]; (predicate: (value: Intl.NumberRangeFormatPart, index: number, array: Intl.NumberRangeFormatPart[]) => unknown, thisArg?: any): Intl.NumberRangeFormatPart[]; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>(part) => part.type !== "approximatelySign" : (part: Intl.NumberRangeFormatPart) => boolean
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>part : Intl.NumberRangeFormatPart
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
>part.type !== "approximatelySign" : boolean
> : ^^^^^^^
>part.type : keyof Intl.NumberFormatRangePartTypeRegistry
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>part : Intl.NumberRangeFormatPart
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
>type : keyof Intl.NumberFormatRangePartTypeRegistry
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>"approximatelySign" : "approximatelySign"
> : ^^^^^^^^^^^^^^^^^^^

.map((part) => part.value)
>map : <U>(callbackfn: (value: Intl.NumberRangeFormatPart, index: number, array: Intl.NumberRangeFormatPart[]) => U, thisArg?: any) => U[]
> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^
>(part) => part.value : (part: Intl.NumberRangeFormatPart) => string
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>part : Intl.NumberRangeFormatPart
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
>part.value : string
> : ^^^^^^
>part : Intl.NumberRangeFormatPart
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
>value : string
> : ^^^^^^

.join("");
>join : (separator?: string) => string
> : ^ ^^^ ^^^^^
>"" : ""
> : ^^

27 changes: 20 additions & 7 deletions tests/cases/conformance/es2023/intlNumberFormatES2023.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,23 @@ new Intl.NumberFormat('en-GB').formatRange(10n, 1000n);
new Intl.NumberFormat('en-GB').formatRangeToParts(10, 1000)[0];
new Intl.NumberFormat('en-GB').formatRangeToParts(10n, 1000n)[0];

// Arbitrary-precision string arguments
new Intl.NumberFormat('en-GB').format('-12.3E-4');
new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8');
new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8');
new Intl.NumberFormat('en-GB').format('Infinity');
new Intl.NumberFormat('en-GB').format('-Infinity');
new Intl.NumberFormat('en-GB').format('+Infinity');
// Arbitrary-precision string arguments
new Intl.NumberFormat('en-GB').format('-12.3E-4');
new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8');
new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8');
new Intl.NumberFormat('en-GB').format('Infinity');
new Intl.NumberFormat('en-GB').format('-Infinity');
new Intl.NumberFormat('en-GB').format('+Infinity');

// Test approximatelySign part type
const nf = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "EUR",
maximumFractionDigits: 0,
});
Comment on lines +37 to +41
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file consistently uses single quotes for string literals (e.g. earlier Intl.NumberFormat calls). Consider switching these newly added string literals to single quotes as well to match the existing style and keep baselines stable.

Copilot uses AI. Check for mistakes.

const filtered = nf
.formatRangeToParts(100, 100)
.filter((part) => part.type !== "approximatelySign")
.map((part) => part.value)
.join("");
Comment on lines +45 to +47
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the rest of this conformance test (which uses single quotes), consider using single quotes for "approximatelySign" and the join separator here as well.

Copilot uses AI. Check for mistakes.
Loading