-
Notifications
You must be signed in to change notification settings - Fork 12.8k
NumberFormatOptions is missing several options including notation #36533
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
Comments
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 Can this issue be reopened or I can create a new one if preffered? |
same need +1 |
@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 |
I get the same error in function getFormattedDistance(distance: number): string {
return distance.toLocaleString('en-US', {
style: 'unit',
unit: 'kilometer',
unitDisplay: 'narrow',
});
} Argument of type '{ style: string; unit: string; unitDisplay: string; }' is not assignable to parameter of type 'NumberFormatOptions'.ts(2345) |
I think is related to the TS version/config, I've tested in TypeScript TS Playground and then in my current project with this config:
And everything went ok. Hope this helps. |
'trailingZeroDisplay' does not exist in type 'NumberFormatOptions'.ts(2769) |
|
I resolved this error by changing lib and target to |
notation
is missing fromNumberFormatOptions
TypeScript/lib/lib.es5.d.ts
Line 4236 in 91ffa1c
TypeScript Version: 3.7.5
Search Terms: NumberFormatOptions notation
Code
https://github.com/chartjs/Chart.js/blob/5f24b97bbfff52975c801b0a0b8880b2aa3b0a6a/src/core/core.ticks.js#L57
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
The text was updated successfully, but these errors were encountered: