As you can see below, Intl.NumberFormat.formatToParts
seems to be missing from Microsoft Edge:
However, both MDN and CanIUse tell me I can...
What am I supposed to do? I can't seem to find any website speaking about this issue, nor can I find a polyfill (EDIT: a polyfill is actually available on MDN, but as I said in my last phrase, I am more interested in the reasons why this method is missing whereas both MDN and CanIUse say it is available on Edge).
I am using it like this:
return (_numberFormat as any).formatToParts(val).map(({type, value}) => {
if (type === 'group')
return ' ';
return value;
}).reduce((string, part) => string + part);
(all I am doing is using a proper space character instead of the unicode default one, which is too slim for the liking of my client)
I know I could work around this (performing a basic format, and replacing the unicode space myself afterwards, or implementing a polyfill), but I am far more intrigued by the fact that this method does not seem to exist on Edge whereas everyone on Earth seems convinced that it does.
Any input appreciated :)
Kind regards,
The methods really are missing in Edge:
console.log(typeof Intl.NumberFormat.prototype.formatToParts);
console.log(typeof Intl.DateTimeFormat.prototype.formatToParts);
function
in Firefox and undefined
in Edge.
Possibly the MDN article was mislead by Microsoft typing the functions in TypeScript (which has nothing to do with them being implemented in Edge) and listing the issue as fixed.
Note that google links for MSDN articles on formatToParts now simply redirect to MDN.
Update regarding listing of Edge support on MDN (https://github.com/mdn/browser-compat-data/pull/3769) (reported in comment by foolip).
Testing and investigation confirms formatFromParts
support was added in Edge 18.
However this had not been pushed to my machine through Windows Update as of April 09 2019 (yesterday), and Edge is showing its version information as "Microsoft Edge 42.17134.1.0 EdgeHTML 17.134" under (hamburger dots > settings > about this app). Googling "has windows 1810 been pushed through windows update" reveals a troublesome history which goes as long way to explaining why I am still running Win 1803 and Edge 17.
I suggest the support page on MDN would benefit by replacing "yes" for Edge support with "18" to remove the confusion.