Intl.NumberFormat: Add latest options, fix previous library discrepancies#56902
Intl.NumberFormat: Add latest options, fix previous library discrepancies#56902sandersn merged 23 commits intomicrosoft:mainfrom
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. |
|
Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 90b7d94. You can monitor the build here. Update: The results are in! |
|
Heya @jakebailey, I've started to run the tarball bundle task on this PR at 90b7d94. You can monitor the build here. |
|
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! |
sandersn
left a comment
There was a problem hiding this comment.
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.
| 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.
NumberFormatPartTypeRegistry
ES2018
- literal
- nan
- infinity
- percent
- integer
- group
- decimal
- fraction
- plusSign
- minusSign
- percentSign
- currency
ES2020
- compact
- exponentInteger
- exponentMinusSign
- exponentSeparator
- unit
- unknown
| declare namespace Intl { | ||
| interface NumberFormat { | ||
| format(value: number | bigint): string; | ||
| resolvedOptions(): ResolvedNumberFormatOptions; |
There was a problem hiding this comment.
duplicated with entry in es5, doesn't need to be here
| exceptZero: any; | ||
| } | ||
|
|
||
| type NumberFormatOptionsSignDisplay = keyof NumberFormatOptionsSignDisplayRegistry; |
There was a problem hiding this comment.
ES2020
- auto
- never
- always
- exceptZero
ES2023
- negative
| currency: any; | ||
| } | ||
|
|
||
| type NumberFormatOptionsStyle = keyof NumberFormatOptionsStyleRegistry; |
There was a problem hiding this comment.
ES5
- decimal
- percent
- currency
ES2020
- unit
| name: any; | ||
| } | ||
|
|
||
| type NumberFormatOptionsCurrencyDisplay = keyof NumberFormatOptionsCurrencyDisplayRegistry; |
There was a problem hiding this comment.
ES5
- code
- symbol
- name
ES2020
- narrowSymbol
|
|
||
| type NumberFormatOptionsCurrencyDisplay = keyof NumberFormatOptionsCurrencyDisplayRegistry; | ||
|
|
||
| interface NumberFormatOptionsUseGroupingRegistry {} |
|
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.useGroupingis 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.