最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

VS Code code formatting JavaScript incorrectly - Stack Overflow

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论