How to implement Nullable feature in es6? I need to support the source code of my previous co-worker, who used too much destructuring feature of es6. Something like this, every where:
dispatch(
loadImports(response.items.map(({ importRecord: { ['import']: importId } }) => importId))
)
In this example, it's possible that I may get TypeError: Cannot read property 'import' of null
error.
I don't want to rewrite the whole destructures to regular conditions. Or if there isn't, how to deal with them, without rewriting?
UPD:
Expected version by co-worker: https://jsbin.com/fesewiy/edit?js,console
Current version: https://jsbin.com/qirixil/edit?js,console