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

# #!/JoePea (3 months 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 (3 months ago)

I was hoping to avoid things like

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

#!/JoePea

# Jordan Harband (3 months ago)
# #!/JoePea (20 days ago)

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