Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Must the optional chain end with .?propName? #1

Open
brad4d opened this issue Jul 6, 2023 · 1 comment
Open

Must the optional chain end with .?propName? #1

brad4d opened this issue Jul 6, 2023 · 1 comment
Labels
question Further information is requested

Comments

@brad4d
Copy link

brad4d commented Jul 6, 2023

Would this be legal syntax?

maybeUndef?.method().prop = something;
@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Jul 7, 2023

That would be valid: this proposal re-uses the existing optional chaining syntax with no additional restrictions other than "it cannot end with a function call". This is so that developers can re-using their existing knowledge about assignment to member expressions and about optional chaining, without having to remember that when used together there are arbitrary additional restrictions.

The readme shows expr1?.foo().prop[key] = val as an example.

@nicolo-ribaudo nicolo-ribaudo added the question Further information is requested label Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants