formatjs / handlebars-intl

Handlebars helpers for internationalization.
http://formatjs.io/handlebars/
Other
265 stars 28 forks source link

formatNumber: only a number is accepted #84

Open sergey-be opened 7 years ago

sergey-be commented 7 years ago

formatNumber helper explicitly verifies the type of a value and throws an exception if it's other than number. But Internationalization API Specification doesn't put such a restriction and Intl.NumberFormat().format() function accepts the argument of any type. So the following examples are perfectly legitimate:

const format = new Intl.NumberFormat().format;
format('1234.56'); // ==> 1,234.56
format({valueOf: () => 56789.01}); // ==> 56,789.01
format(new Date()); // ==> 1,476,977,151,388

I would also expect from this helper to accept a value of any type.

Thank you.