You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example code (might not compile, but hopefully illustrates the point):
// compilation time - note that the only difference in formatters is the number formatter optionsconstunitFormatOptions1={numberFormatter: globalizeInstance.numberFormatter({minimumIntegerDigits: 1})};constunitFormatOptions2={numberFormatter: globalizeInstance.numberFormatter({minimumIntegerDigits: 2})};compileFormatters([globalizeInstance.unitFormatter('hour',unitFormatOptions1),globalizeInstance.unitFormatter('hour',unitFormatOptions2)]);// ... now to the runtimeconstx=globalizeInstance.formatUnit(3,'hour',unitFormatOptions1);consty=globalizeInstance.formatUnit(3,'hour',unitFormatOptions2);
Expected: x == "3" and y== "03"
Actual: x == "3" and y == "3"
The problem is that the unit formatter takes a number formatter (a function) as one of its options, but the runtime keys are generated by JSON.stringifying the options (see here), and JSON.stringify stringifies functions as empty string.
So, the runtime key is resolved to the same thing in both formatters, even though they have different number formatters.