22:02
<ptomato>
I'd like to do an informal poll! about coercion to integers in the context of Temporal
22:03
<ptomato>
precedent in JS is to convert all sorts of nonsensical values to 0 if an integer is expected:
22:03
<ptomato>
[1, 2, 3].slice(NaN) // => [1, 2, 3]
[1, 2, 3].slice("foo") // => [1, 2, 3]
[1, 2, 3].slice(/regex/) // => [1, 2, 3]
[1, 2, 3].slice(Math) // => [1, 2, 3]
22:04
<ptomato>
but not universally:
22:04
<ptomato>
[].length = NaN // RangeError
String.fromCodePoint("foo") // RangeError
22:05
<ptomato>
Temporal entry points currently work like the former
22:06
<ptomato>
this leads to several bug-prone situations:
22:06
<ptomato>
new Temporal.Duration("foo") // => zero-length duration 😱
Temporal.PlainDateTime.from("2022-03-20T00:00").add({days: NaN}) // => 2022-03-20T00:00 😱
22:07
<ptomato>
therefore we are considering changing this coercion to an integer to be more restrictive
22:08
<ptomato>
I'd like to figure out if people are generally comfortable with this or it is likely to provoke a lot of discussion
22:11
<ptomato>
please react: 🤷 = I don't feel particularly strongly about this 🐛 = I feel strongly that bug-prone situations such as these should be avoided ⚖️ = I feel strongly that consistency with the precedent is most important
22:12
<ptomato>
(for more in-depth information, see https://github.com/tc39/proposal-temporal/issues/2112)