Skip to content

"exceptZero" for "signDisplay" option of Intl.NumberFormat() constructor options object #46712

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

Closed
bolatovumar opened this issue Nov 6, 2021 · 5 comments · Fixed by #46740
Closed
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Milestone

Comments

@bolatovumar
Copy link

lib Update Request

In TS 4.4.4 signDisplay options of Intl.NumberFormat() constructor options object used to be of type string. See here:

signDisplay?: string;

That was changed in this PR: #45647. Now it's of type "auto" | "never" | "always" | undefined. However, I believe this type union is incomplete and should also include "exceptZero" (see MDN and spec links below). As a result starting from TS 4.5.0-beta (or possibly earlier, I didn't test versions between 4.4.4 and 4.5.0-beta) you now get an error if you try to instantiate Intl.NumberFormat with signDisplay option set to "exceptZero".

Configuration Check

My compilation target is ES2015 and my lib is the default.

Missing / Incorrect Definition

I'm expecting "exceptZero" to be a valid value for signDisplay option of Intl.NumberFormat() constructor options object.

Sample Code

const numberFormatter = new Intl.NumberFormat('en', {
    signDisplay: 'exceptZero' // expect `exceptZero` to be a valid value but it's not according to type definitions
});

Documentation Link

See MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#parameters
See spec: https://402.ecma-international.org/7.0/#sec-getoption

@DanielRosenwasser DanielRosenwasser added Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Nov 9, 2021
@DanielRosenwasser DanielRosenwasser added this to the Backlog milestone Nov 9, 2021
@iAziz786
Copy link
Contributor

iAziz786 commented Nov 9, 2021

I would like to pick this issue.

@iAziz786
Copy link
Contributor

iAziz786 commented Nov 9, 2021

I assume adding the missing type in the union will do the work?

@bolatovumar
Copy link
Author

@iAziz786 yeah, that's correct.

@iAziz786
Copy link
Contributor

Cool, @DanielRosenwasser may I request for the PR to review by anyone?

@ArthurGuez
Copy link

Hi there,

I've updated Typescript to 4.5.5 but I'm still having the aforementioned issue. Has the fix been applied?

eemeli added a commit to messageformat/messageformat that referenced this issue Feb 6, 2022
… 4.5

Some @ts-ignore comments are required for signDisplay: 'exceptZero' due to
microsoft/TypeScript#46712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants