VSCodeBeautify
VSCodeBeautify copied to clipboard
Adding space before and after "?" when we are using it for checking if key existing
let obj = { "key" : { "key1" : "value" } }
if(obj.key?.key1?){ //when i format it. It is converted to obj.key ? .key1 ? ) which is not valid. //do something }
You doing it wrong...
let obj = {
"key": {
"key1": "value"
}
}
if (obj.key.key1) {
//do something
console.log('true');
}else{
console.log('false');
}
/*OR*/
obj.key.key1 ? console.log('true') : console.log('false');
having same issue, @jagadeeshgade008 syntax is fine, the included version of beautifier is messing it up.
https://github.com/beautify-web/js-beautify/issues/1727
@jagadeeshgade008 update the bundled version of js-beautifer: https://github.com/HookyQR/VSCodeBeautify/issues/346
After doing this, I had to restart VS Code and reload the plugin.