-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Intl.NumberFormat: Add latest options, fix previous library discrepancies #56902
Conversation
- move properties to correct spec versions - non-optional ResolvedNumberFormatOptions properties
a433b81
to
0b137b9
Compare
As per ECMA-402 v10 / 15.1.2 microsoft#22-28 Boolean(true), Boolean(false), String("true") and String("false") all have different behaviour, for reasons known unto God
Includes test for conditional useGrouping override in lib.es5.d.ts
Remove redundant/outdated esnext.bigint test CRLF
This should be ready for review. Context for some less-obvious changes:
I'd be grateful if someone could run top100/dt when convenient. |
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@jakebailey Here they are:
CompilerComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
StartupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Something interesting changed - please have a look. Details
|
Hey @jakebailey, the results of running the DT tests are ready. |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
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.
I think this is good to go, although I'd like to wait until after the beta.
The only question I have is about any
as the property type for registries. Everything else is notes for myself about the combined members of registries.
@@ -37,10 +37,22 @@ declare namespace Intl { | |||
|
|||
const PluralRules: PluralRulesConstructor; | |||
|
|||
// We can only have one definition for 'type' in TypeScript, and so you can learn where the keys come from here: | |||
type ES2018NumberFormatPartType = "literal" | "nan" | "infinity" | "percent" | "integer" | "group" | "decimal" | "fraction" | "plusSign" | "minusSign" | "percentSign" | "currency" | "code" | "symbol" | "name"; |
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
- literal
- nan
- infinity
- percent
- integer
- group
- decimal
- fraction
- plusSign
- minusSign
- percentSign
- currency
ES2020
- compact
- exponentInteger
- exponentMinusSign
- exponentSeparator
- unit
- unknown
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated with entry in es5, doesn't need to be here
exceptZero: any; | ||
} | ||
|
||
type NumberFormatOptionsSignDisplay = keyof NumberFormatOptionsSignDisplayRegistry; |
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.
ES2020
- auto
- never
- always
- exceptZero
ES2023
- negative
currency: any; | ||
} | ||
|
||
type NumberFormatOptionsStyle = keyof NumberFormatOptionsStyleRegistry; |
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.
ES5
- decimal
- percent
- currency
ES2020
- unit
name: any; | ||
} | ||
|
||
type NumberFormatOptionsCurrencyDisplay = keyof NumberFormatOptionsCurrencyDisplayRegistry; |
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.
ES5
- code
- symbol
- name
ES2020
- narrowSymbol
|
||
type NumberFormatOptionsCurrencyDisplay = keyof NumberFormatOptionsCurrencyDisplayRegistry; | ||
|
||
interface NumberFormatOptionsUseGroupingRegistry {} |
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.
ES2023
- min2
- auto
- always
Updated the registry interfaces as discussed. I've also included one other minor change. The defined behaviour of the resolved options |
@typescript-bot test top200 |
Heya @sandersn, I've started to run the parallelized Definitely Typed test suite on this PR at 254a8ce. You can monitor the build here. Update: The results are in! |
Heya @sandersn, I've started to run the diff-based user code test suite on this PR at 254a8ce. You can monitor the build here. Update: The results are in! |
Heya @sandersn, I've started to run the diff-based top-repos suite on this PR at 254a8ce. You can monitor the build here. Update: The results are in! |
@sandersn Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Something interesting changed - please have a look. Details
|
Hey @sandersn, the results of running the DT tests are ready. |
@sandersn Here are the results of running the top-repos suite comparing Everything looks good! |
Can't wait for this to land! |
I forgot to check whether CI had run recently when I merged, and this PR adds a new section to every resolution trace baseline.
Fixes #56269
Fixes #52072
Fixes #43336
keyof <RegistryInterface>
in order to make them extensible, as per precedent. This is technically breaking, and will likely need to be tested against high-exposure libraries for side-effects.useGrouping
is a bit of a mess, as the property's primitive type was changed in version 10. The inclusion of"true"
and"false"
as acceptable values in the es2023 implementation is intentional, as per the specification.