Skip to content

Adds [unit] and [unitDisplay] to NumberFormatOptions #38013

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

Merged
merged 5 commits into from
Jun 18, 2020

Conversation

obber
Copy link
Contributor

@obber obber commented Apr 16, 2020

Fixes #38012.

Adds the unit and unitDisplay option to NumberFormatOptions in src/lib/es5.d.ts

@msftclas
Copy link

msftclas commented Apr 16, 2020

CLA assistant check
All CLA requirements met.

@sandersn sandersn self-assigned this May 5, 2020
@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label May 5, 2020
@barrymay
Copy link

This PR is perfectly fine, but while you're at it would be nice to get notation in there too :)

@BPScott
Copy link

BPScott commented May 22, 2020

Notation is covered in #37721

@BPScott
Copy link

BPScott commented Jun 18, 2020

Yo @sandersn, any chance we'd be able to address before beta release in addition to #38013?

I think this needs to be updated to go in es2020.intl.d.ts same as #38013

Copy link
Contributor

@orta orta left a comment

Choose a reason for hiding this comment

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

Did a read through some of the docs, looks good to me

@sandersn
Copy link
Member

sandersn commented Jun 18, 2020

I'll move this over to es2020.intl.d.ts

@sandersn sandersn merged commit 37831de into microsoft:master Jun 18, 2020
@JonathanDCohen
Copy link

JonathanDCohen commented Dec 17, 2020

What's going on with this? I'm using Typescript 4.1.3 and still getting an error Argument of type '{ style: string; unit: string; }' is not assignable to parameter of type 'NumberFormatOptions'. Object literal may only specify known properties, and 'unit' does not exist in type 'NumberFormatOptions'.

I'm similarly getting internationalized units by using formatToParts(0).find((part => part.type === 'unit')).value and getting an error This condition will always return 'false' since the types 'NumberFormatPartTypes' and '"unit"' have no overlap.

edit: adding "ES2020" to my "lib" option in my tsconfig fixes the first issue, but the second persists. I checked the definition and sure enough "unit" was missed from potential part types.

Reported in #42004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

NumberFormatOptions interface is missing unit and unitDisplay properties.
7 participants