Skip to content

Allow optional chaining operator in JS

Simon Knox requested to merge psimyn-add-babel-chaining into master

What does this MR do?

Changes your life. You may never have to write && again.

Instead of writing gl && gl.currentUser && gl.currentUser.name

write gl?.currentUser?.name!!

Or checking things in DOM where the element may or may not exist:

document.querySelector('input[name=foo]')?.value

NB: This is still stage 1 proposal. But a pretty great thing. And all the items mentioning stage 2 are checked off

Does this MR meet the acceptance criteria?

Edited by Simon Knox

Merge request reports