Repository navigation
Intl.NumberFormatOptions options are missing #52072
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Milestone
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Activity
sirbrillig commentedon Jan 6, 2023
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 commentedon Sep 6, 2023
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