-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Intl.NumberFormat: Add latest options, fix previous library discrepancies #56902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df89080
f9612a0
50e295d
7a9f949
ef87a15
8b96367
0b137b9
bb13158
b857806
481c244
0734e7a
d0876e5
72f7d44
7b73dc7
6ee47d4
f8e9dda
ca699fc
40cdb05
a6261f9
90b7d94
37c5d52
ff58e75
254a8ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
declare namespace Intl { | ||
interface DateTimeFormatPartTypesRegistry { | ||
unknown: any; | ||
unknown: never; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -705,6 +705,5 @@ interface DataView { | |
declare namespace Intl { | ||
interface NumberFormat { | ||
format(value: number | bigint): string; | ||
resolvedOptions(): ResolvedNumberFormatOptions; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. duplicated with entry in es5, doesn't need to be here |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,24 +223,49 @@ declare namespace Intl { | |
): UnicodeBCP47LocaleIdentifier[]; | ||
}; | ||
|
||
interface NumberFormatOptionsStyleRegistry { | ||
unit: never; | ||
} | ||
|
||
interface NumberFormatOptionsCurrencyDisplayRegistry { | ||
narrowSymbol: never; | ||
} | ||
|
||
interface NumberFormatOptionsSignDisplayRegistry { | ||
auto: never; | ||
never: never; | ||
always: never; | ||
exceptZero: never; | ||
} | ||
|
||
type NumberFormatOptionsSignDisplay = keyof NumberFormatOptionsSignDisplayRegistry; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ES2020
ES2023
|
||
|
||
interface NumberFormatOptions { | ||
numberingSystem?: string | undefined; | ||
compactDisplay?: "short" | "long" | undefined; | ||
notation?: "standard" | "scientific" | "engineering" | "compact" | undefined; | ||
signDisplay?: "auto" | "never" | "always" | "exceptZero" | undefined; | ||
signDisplay?: NumberFormatOptionsSignDisplay | undefined; | ||
unit?: string | undefined; | ||
unitDisplay?: "short" | "long" | "narrow" | undefined; | ||
currencyDisplay?: string | undefined; | ||
currencySign?: string | undefined; | ||
currencySign?: "standard" | "accounting" | undefined; | ||
} | ||
|
||
interface ResolvedNumberFormatOptions { | ||
compactDisplay?: "short" | "long"; | ||
notation?: "standard" | "scientific" | "engineering" | "compact"; | ||
signDisplay?: "auto" | "never" | "always" | "exceptZero"; | ||
notation: "standard" | "scientific" | "engineering" | "compact"; | ||
signDisplay: NumberFormatOptionsSignDisplay; | ||
unit?: string; | ||
unitDisplay?: "short" | "long" | "narrow"; | ||
currencyDisplay?: string; | ||
currencySign?: string; | ||
currencySign?: "standard" | "accounting"; | ||
} | ||
|
||
interface NumberFormatPartTypeRegistry { | ||
compact: never; | ||
exponentInteger: never; | ||
exponentMinusSign: never; | ||
exponentSeparator: never; | ||
unit: never; | ||
unknown: never; | ||
} | ||
|
||
interface DateTimeFormatOptions { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/// <reference lib="es2022" /> | ||
/// <reference lib="es2023.array" /> | ||
/// <reference lib="es2023.collection" /> | ||
/// <reference lib="es2023.intl" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
declare namespace Intl { | ||
interface NumberFormatOptionsUseGroupingRegistry { | ||
min2: never; | ||
auto: never; | ||
always: never; | ||
} | ||
|
||
interface NumberFormatOptionsSignDisplayRegistry { | ||
negative: never; | ||
} | ||
|
||
interface NumberFormatOptions { | ||
roundingPriority?: "auto" | "morePrecision" | "lessPrecision" | undefined; | ||
roundingIncrement?: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000 | undefined; | ||
roundingMode?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined; | ||
trailingZeroDisplay?: "auto" | "stripIfInteger" | undefined; | ||
} | ||
|
||
interface ResolvedNumberFormatOptions { | ||
roundingPriority: "auto" | "morePrecision" | "lessPrecision"; | ||
roundingMode: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven"; | ||
roundingIncrement: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000; | ||
trailingZeroDisplay: "auto" | "stripIfInteger"; | ||
} | ||
|
||
interface NumberRangeFormatPart extends NumberFormatPart { | ||
source: "startRange" | "endRange" | "shared"; | ||
} | ||
|
||
interface NumberFormat { | ||
formatRange(start: number | bigint, end: number | bigint): string; | ||
formatRangeToParts(start: number | bigint, end: number | bigint): NumberRangeFormatPart[]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4415,12 +4415,33 @@ declare namespace Intl { | |
|
||
var Collator: CollatorConstructor; | ||
|
||
interface NumberFormatOptionsStyleRegistry { | ||
decimal: never; | ||
percent: never; | ||
currency: never; | ||
} | ||
|
||
type NumberFormatOptionsStyle = keyof NumberFormatOptionsStyleRegistry; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ES5
ES2020
|
||
|
||
interface NumberFormatOptionsCurrencyDisplayRegistry { | ||
code: never; | ||
symbol: never; | ||
name: never; | ||
} | ||
|
||
type NumberFormatOptionsCurrencyDisplay = keyof NumberFormatOptionsCurrencyDisplayRegistry; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ES5
ES2020
|
||
|
||
interface NumberFormatOptionsUseGroupingRegistry {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ES2023
|
||
|
||
type NumberFormatOptionsUseGrouping = {} extends NumberFormatOptionsUseGroupingRegistry ? boolean : keyof NumberFormatOptionsUseGroupingRegistry | "true" | "false" | boolean; | ||
type ResolvedNumberFormatOptionsUseGrouping = {} extends NumberFormatOptionsUseGroupingRegistry ? boolean : keyof NumberFormatOptionsUseGroupingRegistry | false; | ||
|
||
interface NumberFormatOptions { | ||
localeMatcher?: string | undefined; | ||
style?: string | undefined; | ||
localeMatcher?: "lookup" | "best fit" | undefined; | ||
style?: NumberFormatOptionsStyle | undefined; | ||
currency?: string | undefined; | ||
currencySign?: string | undefined; | ||
useGrouping?: boolean | undefined; | ||
currencyDisplay?: NumberFormatOptionsCurrencyDisplay | undefined; | ||
useGrouping?: NumberFormatOptionsUseGrouping | undefined; | ||
minimumIntegerDigits?: number | undefined; | ||
minimumFractionDigits?: number | undefined; | ||
maximumFractionDigits?: number | undefined; | ||
|
@@ -4431,14 +4452,15 @@ declare namespace Intl { | |
interface ResolvedNumberFormatOptions { | ||
locale: string; | ||
numberingSystem: string; | ||
style: string; | ||
style: NumberFormatOptionsStyle; | ||
currency?: string; | ||
currencyDisplay?: NumberFormatOptionsCurrencyDisplay; | ||
minimumIntegerDigits: number; | ||
minimumFractionDigits: number; | ||
maximumFractionDigits: number; | ||
minimumFractionDigits?: number; | ||
maximumFractionDigits?: number; | ||
minimumSignificantDigits?: number; | ||
maximumSignificantDigits?: number; | ||
useGrouping: boolean; | ||
useGrouping: ResolvedNumberFormatOptionsUseGrouping; | ||
} | ||
|
||
interface NumberFormat { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
declare namespace Intl { | ||
interface NumberRangeFormatPart extends NumberFormatPart { | ||
source: "startRange" | "endRange" | "shared"; | ||
} | ||
|
||
interface NumberFormat { | ||
formatRange(start: number | bigint, end: number | bigint): string; | ||
formatRangeToParts(start: number | bigint, end: number | bigint): NumberRangeFormatPart[]; | ||
} | ||
// Empty | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NumberFormatPartTypeRegistry
ES2018
ES2020