VS Code code formatting JavaScript incorrectly

Viewed 1496

As above, and presented in the screenshot.

Using Format document on valid JS code (no space between question marks) produces errors.

What I've tried so far was to change formatter, but to no avail. Error is especially irritating because I have formatting on save option on and I like it that way. Studio version is 1.46.

If you want to reproduce it yourself, feel free:

let iForgotToInitializeThat = undefined;
const coalesceResult = iForgotToInitializeThat ?? 'something';

And try to format it. Code making curious decision

2 Answers

I've tried your code and it works properly in my case, but have prettier formatter extension configured to format my code, maybe you can try it.

Hope it helps :)

If you use Beautify then it will indicate an error. Try to use Prettier.

Related