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

Throw RangeError if dateStyle/timeStyle is attempted with required equals to the other. #47

Closed zbraniecki closed 4 years ago

zbraniecki commented 4 years ago

Fixes the remaining piece of #35.

zbraniecki commented 4 years ago

@littledan, @anba - does it look good to you?

zbraniecki commented 4 years ago

Depending on the resolution of #46 I may shift it to TypeError prior or after landing.

anba commented 4 years ago

The possible values for required and defaults are:

And we only want to throw for:

So I think the error conditions should be:

zbraniecki commented 4 years ago

Ah, right! We don't want to throw on required = "any". I updated the patch.

@anba can you take another look for r?

anba commented 4 years ago

LGTM!

Can you add the two new steps below the existing two Get calls for date/timeStyle, instead of moving all steps before If required is "date" or "any", then? That way the Get calls in ToDateTimeOptions for the individual properties will be executed in the same order as in InitializeDateTimeFormat.