admin管理员组

文章数量:1379427

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.

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.

Share Improve this question asked Jun 18, 2020 at 13:13 matek997matek997 3511 silver badge13 bronze badges 4
  • Everything working. – demkovych Commented Jun 18, 2020 at 13:15
  • what's the ?? for – William Ku Commented Jun 18, 2020 at 13:16
  • Install Nullish Coalescing Operator Grammar – demkovych Commented Jun 18, 2020 at 13:18
  • @WilliamKun developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – matek997 Commented Jun 18, 2020 at 13:22
Add a ment  | 

4 Answers 4

Reset to default 5

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.

In my case, a formatter was installed along side prettier, which was deprecated and causing spaces. Its always good idea to disable extensions one by one and see which is causing problem.

In my case, I removed Beautify that is a deprecated extension. and then that problem was fixed.

本文标签: VS Code code formatting JavaScript incorrectlyStack Overflow