notation is missing from NumberFormatOptions
TypeScript Version: 3.7.5
Search Terms: NumberFormatOptions notation
Code
const str = new Intl.NumberFormat(undefined, {notation: 'scientific'}).format(100000);
Expected behavior:
I should be able to use NumberFormat's notation option. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
Actual behavior:
src/core/core.ticks.js(57,43): error TS2345: Argument of type '{ notation: string; minimumFractionDigits: number; maximumFractionDigits: number; }' is not assignable to parameter of type 'NumberFormatOptions'.
Playground Link: None
Related Issues: None
Commonly the TypeScript team does not add experimental APIs to the standard library definitions.
You can use Declaration Merging to extend the types yourself. There's probably also a npm package out there that does this for you.
Thanks!
@MartinJohns notation is not experimental anymore. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/NumberFormat
Can this issue be reopened or I can create a new one if preffered?
@MartinJohns
notationis not experimental anymore. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/NumberFormatCan this issue be reopened or I can create a new one if preffered?
same need +1
@benmccann Any workaround for this for now?
@benmccann Any workaround for this for now?
const shortAmount = new Intl.NumberFormat(undefined, {
//@ts-ignore
notation: "compact",
compactDisplay: "short"
}).format(parseInt(value));
I think the only solution for now is to add a ts-ignore until the types definitions are updated.
Most helpful comment
@MartinJohns
notationis not experimental anymore. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/NumberFormatCan this issue be reopened or I can create a new one if preffered?