refactor: utilize type narrowing (#33075)

PR Close #33075
This commit is contained in:
Danny Skoog
2019-10-09 17:17:52 +02:00
committed by Miško Hevery
parent 1ae77da609
commit 6ab5f3648a
29 changed files with 73 additions and 80 deletions

View File

@ -94,9 +94,9 @@ export class NgLocaleLocalization extends NgLocalization {
export function getPluralCase(locale: string, nLike: number | string): Plural {
// TODO(vicb): lazy compute
if (typeof nLike === 'string') {
nLike = parseInt(<string>nLike, 10);
nLike = parseInt(nLike, 10);
}
const n: number = nLike as number;
const n: number = nLike;
const nDecimal = n.toString().replace(/^[^.]*\.?/, '');
const i = Math.floor(Math.abs(n));
const v = nDecimal.length;

View File

@ -50,7 +50,7 @@ function formatNumber(
}
}
return NumberFormatter.format(value as number, locale, style, {
return NumberFormatter.format(value, locale, style, {
minimumIntegerDigits: minInt,
minimumFractionDigits: minFraction,
maximumFractionDigits: maxFraction,