still round numbers when not formatting them (#9653)

This commit is contained in:
Bram Kragten 2021-07-30 17:36:31 +02:00 committed by GitHub
parent 0ed5454d02
commit 5234e9bce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { FrontendLocaleData, NumberFormat } from "../../data/translation";
import { round } from "../number/round";
export const numberFormatToLocale = (
localeOptions: FrontendLocaleData
@ -60,7 +61,12 @@ export const formatNumber = (
).format(Number(num));
}
}
return num.toString();
if (typeof num === "string") {
return num;
}
return `${round(num, options?.maximumFractionDigits).toString()}${
options?.style === "currency" ? ` ${options.currency}` : ""
}`;
};
/**