microsoft / microsoft/TypeScript

Intl.NumberFormat does not model required properties when `style` is set to `currency`

Open
#57,514 2 comments 4 reactions 2 assignees View on GitHub

@RyanCavanaugh is already working on this.

Since Sep 19, 2026.

  • #64335 by @copilot-swe-agent — open
Bug Domain: lib.d.ts Help Wanted Needs Human Review
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

⚙ Compilation target

ESNext

⚙ Library

ESNext

Missing / Incorrect Definition

According to the MDN docs, when style is set to currency, then the currency property must be provided.

This could be achieved through a discriminating union on the style property e.g.

interface NumberFormatParamsStyleDecimal {
    style: "decimal"
}

interface NumberFormatParamsStyleCurrency {
    style: "currency"
    currency: string
}

type NumberFormatParams = NumberFormatParamsStyleDecimal | NumberFormatParamsStyleCurrency;

const numberFormat = (params: NumberFormatParams) => {};

numberFormat({
    style: "decimal",
})

numberFormat({
    style: "currency",
    currency: "USD"
})
Sample Code
This fails at runtime, but does not fail compilation:

new Intl.NumberFormat("en", {
    style: "currency",
    currency: undefined
});
VM159:1 Uncaught TypeError: Currency code is required with currency style.
    at new NumberFormat (<anonymous>)
    at <anonymous>:1:1
Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#style

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.