-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw RangeError for invalid "mode" option? #38
Comments
Hm. 262 uses RangeError almost exclusively for numeric arguments. We don't have many positions which take a limited set of strings, but for example I would prefer not to have two different error kinds here. I don't know whether it's worth breaking with 402, though. On the other hand, 402 and Temporal also do coercion of arguments, which we're no longer doing. (Your observation applies equally to the stage-3 base64 proposal, incidentally.) |
Personally, I definitely would find it more intuitive for an invalid enum value to throw a RangeError, since it's not the type that's wrong, it's that it's not in the set of allowed values. |
Uh. I don't know what "type" means if not "the set of allowed values". |
lol i shouldn't have used the word "set" then - it's not in the finite list of allowed values maybe? |
A lot of types are finite lists? Boolean is just the two values "These three specific strings" is no more or less of a type than "all strings". (For example TypeScript will let you represent that type just fine; I expect the types it will add for this proposal will reflect that.) |
I guess String.prototype.normalize is the counterexample where ECMA-262 uses a |
Looking elsewhere, the web platform has a number of methods which take enums ( |
Iterator.zip and Iterator.zipKeyed, step 5:
Temporal and ECMA-402 both throw a
RangeError
for invalid options:Maybe consider changing step 5 to:
The text was updated successfully, but these errors were encountered: