tc39 / proposal-intl-datetime-style

dateStyle and timeStyle options for DateTimeFormat
https://tc39.github.io/proposal-intl-datetime-style/
28 stars 9 forks source link

Use TypeError instead of RangeError when mixing date-/timeStyle with other date/time options #46

Closed anba closed 4 years ago

anba commented 4 years ago

43 used RangeError when other date-time options are used with timeStyle/dateStyle, but TypeError is probably the more accurate error type here.

ECMA-402 currently uses RangeError whenever a value isn't a member of the set of allowed values:

Whereas TypeError is used when a value:

Interpreting that the set of allowed values for the date/time options is reduced to the empty set when timeStyle/dateStyle are present and therefore RangeError is the correct error type is maybe a bit dubious. I'd rather see it more similar to the missing unit or currency case in SetNumberFormatUnitOptions, where a user provided a logically incorrect options object.

zbraniecki commented 4 years ago

That sounds very reasonable to me.

@littledan - can you confirm?

If so, I'll update all uses of RangeError to TypeError.

littledan commented 4 years ago

@anba 's rationale for TypeError rather than RangeError in this case sounds correct to me.

zbraniecki commented 4 years ago

I'm going to replace RangeError with TypeError in the three positions where we added it recently.