DEV Community

Discussion on: TypeScript is wasting my time

Collapse
 
fellz profile image
Roman

You should specify that notation not just the string type but concrete type Intl.NumberFormatOptions['notation']

  function formatNumber(value: number, lang: string = 'en') {
  const options = {
    notation: 'compact' as Intl.NumberFormatOptions['notation'],
    maximumFractionDigits: 1,
  };
   const formatter = Intl.NumberFormat(lang, options);
   return formatter.format(value);
}
Enter fullscreen mode Exit fullscreen mode