Support Optional Chaining operator

I’d love to be able to use expressions like {{myQuery.data?.foo?.bar ? 'baz'}} in my components. The optional chaining operator and its relatives make it much easier to write code that won’t throw exceptions when data is missing.

You could use Babel to compile the JS so all browsers can run it.

5 Likes

Second this! Node and most browsers support this already.

My use case: I’m fetching an user from a database, and I’d like to access a property if it exists, otherwise return a default value: e.g. {{ user.name || “N/A” }}. However if user is not defined, the code segment appears to exit after throwing an exception, resulting in the whole code block returning nothing. Normally I’d do: {{user?.name || “N/A” }} to avoid errors.

1 Like

Optional Chaining appears to be working fine. The current syntax checker is complaining, but just ignore it.

Optional chaining is now fully supported! :smile: Thank you all for your input (and patience) here.