Optional chaining assignment proposal

June 23, 2023 ยท View on GitHub

Basically, allow this:

foo?.bar = value;

which is equivalent to

foo == null ? undefined : (foo.bar = value);

Real-world examples

Use this regexp to find some of them in your codebase: if \((.*?)\)[\s\n]*\{?[\s\n]*\1\.

Babel

shosho

TypeScript