question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Format Document" a TS file removes spaces in curly braces

See original GitHub issue

TS Template added by @mjbvz

TypeScript Version: 4.1.0-dev.20201031

Search Terms

  • jsx
  • format

  • VSCode Version: 1.50.1
  • OS Version: macOS 10.14.6

Steps to Reproduce:

  1. Open a .tsx file
  2. Write something with space inside curly braces, like below. Notice the spaces between expression and brace:
import { ExamplePane } from '../app/App';

...

return (
  <div>
    { this.state.time.toLocaleTimeString() }
  </div>
);
  1. Right click & Format Document, then it becomes:
import { ExamplePane } from '../app/App';    {/* This one is still fine */}

...

return (
  <div>
    { this.state.time.toLocaleTimeString()}   {/* The space before the closing curly brace is gone */}
  </div>
);

Does this issue occur when all extensions are disabled?: Yes

Update: This is it:

https://imgur.com/pA2EDzn

In my project, when I use Format Document, all my files are formatted with the default option like @a-tarasyuk (spaces after opening and before closing braces are removed). Then the issue is that VSCode does not delete the space after open braces.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RyanCavanaughcommented, Nov 10, 2020

This is the correct repo; VS Code uses the formatter in this repo to format tsx code.

Can we get a clarified repro? What are your settings? A ts server log would be ideal

0reactions
MartinJohnscommented, Nov 1, 2020

Furthermore, this one should be at VSCode.

The issue got transferred to the TypeScript repository by @mjbvz.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio 2017 - Space before and after curly braces
However if i press Ctrl + E , Ctrl + D to format the entire document the spacing is removed. How I would...
Read more >
space-in-brackets - ESLint - Pluggable JavaScript Linter
objectsInArrays sets the spacings between the curly braces and square brackets of object literals that are the first or last element in an...
Read more >
Options - Prettier
Prettier ships with a handful of format options. ... See: Angular, TypeScript, Flow. ... Print spaces between brackets in object literals. Valid options:....
Read more >
VS Code - You don't need a formatting extension (Prettier and ...
Use four spaces per indentation, and; Wrap all arrow functions in curly braces. All of the above are just personal preferences, but I...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
I like using JSON configuration format so my code editor helps me. In fact, VSCode understands the Prettier configuration file format via ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found