Optional-chaining / null coalescing
See original GitHub issue- Operating System (+Version): Ubuntu 20.04
- VS Code Version: 1.50.0
- beautify Version: 1.5.0
VS Code settings:
"beautify.config": {
"indent_size": 4,
"indent_char": "\t",
},
"beautify.language": {
"js": {
"type": [
"javascript",
"json",
"jsonc"
],
"filename": [
".jshintrc",
".jsbeautifyrc"
]
},
"css": [
"css",
"less",
"scss"
],
"html": [
"htm",
"html"
]
}
Expected results
When there is chaining or nullish coalescing involved, do not put spaces inbetween ‘?’
let a = {
b: {
c: 1
}
};
var d = a?.b?.c || 0;
Actual results
Space is added inbetween the ‘?’ causing syntax error.
let a = {
b: {
c: 1
}
};
var d = a ? .b ? .c || 0;
Similar issue : https://github.com/beautify-web/js-beautify/issues/1530
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:11
Top Results From Across the Web
Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The nullish coalescing operator may be used after optional chaining in order to build a default value when none was found:.
Read more >How to Use Optional Chaining and Nullish Coalescing in ...
The nullish coalescing operator may be used after optional chaining in order to build a default value when no value is found.
Read more >Optional chaining and nullish coalescing in JavaScript
Optional chaining and nullish coalescing are new JavaScript operators. They have both reached stage 3 in the TC39 process, which means that ...
Read more >Optional Chaining and Nullish Coalescing in TypeScript
Optional chaining allows you to write code that will immediately stop running expressions if it hits a null or undefined . Syntax. The...
Read more >Optional Chaining, Null Coalescing and How They Will ...
Optional Chaining and Nullish Coalescing are available in TypeScript 3.7 and will be part of JavaScript soon. See how you can use them...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The fix to this is just HookyQR updating the beautify-js dependency to a newer version that fixed this issue … it takes less then 30 seconds
@jasonkneen Hey man, thank you, Great Solution!