throw a TypeError for non-Numbers and non-integral Numbers#30
throw a TypeError for non-Numbers and non-integral Numbers#30michaelficarra wants to merge 1 commit intomainfrom
Conversation
|
Why is that better? It's the right type, it's just not in the right range. |
|
@ljharb We still throw a RangeError for out-of-range values. The TypeError is if you pass Strings, Arrays, etc. or non-integral Numbers. |
|
A non-integral number is an out of range value. |
|
I guess this depends on what you think the expressive power of this non-existent type system is. I prefer to consider the domain of the function to be integral Numbers. Alternatives such as Numbers in the range [1, 2**32), integral Numbers in that range, all Numbers (which seems to be your preference), all primitives, or all JavaScript values are all equally as valid depending on what type system we're pretending is producing this TypeError. |
|
To me, "type" is a superset of |
A TypeError is better than a RangeError for these values. Matches what we're doing for the second parameter of
Iterator.prototype.includes: https://tc39.es/proposal-iterator-includes/.