Why can't the left-hand side of an assignment expression use optional chaining?

# #!/JoePea (5 years ago)

This is perfectly fine:

this.foo?.bar?.setBaz(123)

but this is not:

this.foo?.bar?.baz = 123

Why is that not allowed, but function calls are?

I find myself often wanting to do assignments like that. When I am auto-completing things in VS Code (TypeScript), it automatically and awesomely inserts the ? characters, only to fail once I write the assignment part.

#!/JoePea

# #!/JoePea (5 years ago)

I was hoping to avoid things like

const baz = this.foo?.bar?.baz
if (baz) baz.lorem = 123

#!/JoePea

# Jordan Harband (5 years ago)
# #!/JoePea (4 years ago)

There's a good number of upvotes for it. It would be nice. #!/JoePea