Repository navigation
Closed
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
lib Update Request
Configuration Check
My compilation target is ES2015 and my lib is [ "dom", "es5", "es6", "es2017", "scripthost", "es2015.collection", "es2015.promise" ].
Missing / Incorrect Definition
the properties of the Intl.NumberFormatOptions are very generic compared to other Options within the Intl scope. As for example the localeMatcher is only a string. For the Intl.DatetimeFormatOption it is more restrictive. Only 'best fit' and 'lookup' are allowed. Actually nearly every property of the Intl.NumberFormatOptions is not restricted as the MDN docs suggest. It would be nice to have type restrictions similar to other types within Intl.
I think this even applies to other Options-Definitions.
for example: Intl.CollatorOptions
Sample Code
// lib.es5.d.ts
interface DateTimeFormatOptions {
localeMatcher?: "best fit" | "lookup";
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?: "best fit" | "basic";
hour12?: boolean;
timeZone?: string;
}// lib.es5.d.ts
interface NumberFormatOptions {
localeMatcher?: string;
style?: string;
currency?: string;
currencyDisplay?: string;
currencySign?: string;
useGrouping?: boolean;
minimumIntegerDigits?: number;
minimumFractionDigits?: number;
maximumFractionDigits?: number;
minimumSignificantDigits?: number;
maximumSignificantDigits?: number;
}Documentation Link
Reacted by Samy Al Zahrani, Benoît Moreau (ben.12), Tobias Waltl, Hayley Price and Patrick Harböck
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript
Activity
christian98 commentedon Mar 22, 2021
Through the MDN docs i found this specification: https://www.currency-iso.org/en/home/tables/table-a1.html
I extracted the Currency-tags and ended up with this:
Possible Type for `Currency`
The linked MDN docs itself contained these possible values for the NumberingSystem property:
Possible Type for `NumberingSystem`
The MDN docs also referenced this specs for the Unit property. I then generated all possible values.
https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-issanctionedsimpleunitidentifier
Possible Type for `Unit`
orta commentedon Sep 8, 2021
In #45647
NumberFormatOptionswent to string literals for a lot of the parts in . Enough that I think this issue could be closed,Re: the extra type explorations, nice work - I think these are probably a bit long for inclusion into the .d.ts files though
aspiers commentedon Feb 16, 2022
@orta commented on September 8, 2021 11:00 AM:
Please could you explain what you mean by that? I don't see any use of string literals here: https://github.com/microsoft/TypeScript/pull/45647/files#diff-bc5657cc7554ca0c944ccc883a1334694829bce1293fd4fc5f2059cada6c003fR4327-R4337
Why? Maybe I'm missing something, but I'm struggling to understand why a whole bunch of options documented here are missing, for example
roundingMode. Isn't it a genuine issue if Typescript prevents usage of these options?floratmin commentedon Apr 6, 2022
For the NumberformatOptions I found on MDN
There is some incostency for the
useGroupingoption. The previousNumberFormatoption was accepting only boolean. So I would assume that the boolean option will be also allowed for compatibility reasons in newer versions.I checked the ResolvedNumberFormatOptions on Chrome and Firefox, there are many options still not implemented, so I did not include them. Also the
useGroupingoption will become probably of type string. The resolved optionminimumFractionDigitsandmaximumFractionDigitsare not returned when I setminimumSignificantDigitsandmaximumSignificantDigits.CaliosD commentedon Apr 8, 2022
I wonder if there's any update for this issue... 'cause I happened to need
roundingModeoption and only to find it's not supported. :(DPK101 commentedon Apr 26, 2022
Thanks for creating an issue, I am also looking for NumberformatOptions.compactDisplay and NumberformatOptions.notation
Please keep in sync with MDN docs,
btw, any other ways I can achieve showing number 324234252 as "$324M" in current version of my TypeScript "4.6.3" ?
Any help would be appreciated.
Thank you
ben12 commentedon May 8, 2023
The same for the missing
NumberFormatOptions.trailingZeroDisplayThank you.
nbostrom commentedon Nov 8, 2023
Is there any update? I'm still seeing many of these missing options
mariasimo commentedon Jun 26, 2024
I'm running into the same issue, missing "trailingZeroDisplay"