Closed js-choi closed 3 years ago
I'd expect a.b::c?.()
, but since ::
is not a property access, I'm not sure I understand why it'd need to be optional.
Even when a
is nullish, a::b
will still create a non-nullish value: a bound function that will probably always throw a TypeError, depending on b
’s usage of this
. (In other words, null::fn
is not itself nullish.)
So a::b?.()
would not be useful to protect from a
being possibly nullish, since a::b
can never be nullish.
(And we’re trying to ensure that a::b();
is always equivalent to const x = a::b; x();
.)
We probably should allow
a.b?.::c()
, like how we allowa.b?.c()
anda.b?.()
. I will amend the specification later.