Skip to content
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.NumberFormatOptions options are missing #52072

Closed
nick-korolev opened this issue Jan 2, 2023 · 2 comments · Fixed by #56902
Closed

Intl.NumberFormatOptions options are missing #52072

nick-korolev opened this issue Jan 2, 2023 · 2 comments · Fixed by #56902
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@nick-korolev
Copy link

nick-korolev commented Jan 2, 2023

Bug Report

Hi. According to specification Intl.NumberFormat contains numberingSystem option, but typescript throws the error Object literal may only specify known properties, and 'numberingSystem' does not exist in type 'NumberFormatOptions'

🔎 Search Terms

Intl, NumberFormatOptions

🕗 Version & Regression Information

"typescript": "^4.9.4"

💻 Code

I have a monorepo with this structure

root

  • base.tsconfig.json
  • package.json
  • app1
    • index.ts
    • tsconfig.json
    • package.json

base.tsconfig.json

{
  "compilerOptions": {
    "module": "ESNext",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "target": "ESNext",
    "noImplicitAny": true,
    "strictNullChecks": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "allowJs": true,
    "checkJs": false,
    "lib": [
      "esnext",
      "dom"
    ],
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "emitDecoratorMetadata": true,
    "baseUrl": "."
  }
}

app1/tsconfig.json

{
  "extends": "../base.tsconfig.json",
  "compilerOptions": {
    "module": "ESNext",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "target": "ESNext",
    "noImplicitAny": true,
    "strictNullChecks": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "allowJs": true,
    "checkJs": false,
    "lib": [
      "esnext",
      "dom"
    ],
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "emitDecoratorMetadata": true,
    "baseUrl": "."
  }
}

app1/index.ts

const amount = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
  numberingSystem: 'latn'
}).format(1000);

console.log(amount);

🙁 Actual behavior

After type checking typescript throws error

index.ts:4:3 - error TS2345: Argument of type '{ style: string; currency: string; numberingSystem: string; }' is not assignable to parameter of type 'NumberFormatOptions'.
  Object literal may only specify known properties, and 'numberingSystem' does not exist in type 'NumberFormatOptions'.

4   numberingSystem: 'latn'
    ~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in index.ts:4

🙂 Expected behavior

The typescript correctly checks the types that are specified in the specification

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Jan 5, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 5, 2023
@sirbrillig
Copy link

I just ran into this issue myself. Weirdly it's not available in the es2020 definition of ResolvedNumberFormatOptions, even though it is present in the es5 types. It's hard for me to tell when it was added to JS, but for a similar property in Intl.Locale caniuse suggests that it is pretty well supported.

@tiagofilipenunes
Copy link

Following up on this, according to the specification, roundingMode should also be available, but typescript is throwing an error:

Object literal may only specify known properties, and 'roundingMode' does not exist in type 'NumberFormatOptions'.

Caniuse is showing it is widely available as well.

Multiple other options are missing as mentioned in #43336

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 Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants