Skip to content

fix(45501): VS Code removes spaces between empty object literals even if insertSpaceAfterOpeningAndBeforeClosingEmptyBraces is true #45514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2021

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #45501

…abled insertSpaceAfterOpeningAndBeforeClosingEmptyBraces
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Aug 19, 2021
@andrewbranch
Copy link
Member

Should object literals and blocks even be controlled by the same setting?

@a-tarasyuk
Copy link
Contributor Author

@andrewbranch I think it depends., the option name is insertSpaceAfterOpeningAndBeforeClosingEmptyBraces does that mean {} object literals? or only blocks? Maybe formatter should have two options insertSpaceAfterOpeningAndBeforeClosingEmptyBlockBraces, insertSpaceAfterOpeningAndBeforeClosingEmptyObjectLiteralBraces. I think it is a discussable question.

@andrewbranch
Copy link
Member

What do other popular formatters do here?

@a-tarasyuk
Copy link
Contributor Author

@andrewbranch I'm not sure that Prettier has the option to handle spaces between empty braces{}. There is option bracketSpacing, however, it removes spaces between empty braces and leaves in non-empty object literals

{
  "bracketSpacing": true
}

Before

export function foo() { }
export const a = { };
export const b = { x: 1 };

After

export function foo() {}
export const a = {};
export const b = { x: 1 };

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m happy to go with this as more consistent, and we can split into two rules later if there’s demand for it.

@andrewbranch andrewbranch merged commit 076f22b into microsoft:main Aug 24, 2021
andrewbranch added a commit that referenced this pull request Sep 1, 2021
… with enabled insertSpaceAfterOpeningAndBeforeClosingEmptyBraces (#45514)"

This reverts commit 076f22b.
andrewbranch added a commit that referenced this pull request Sep 2, 2021
… with enabled insertSpaceAfterOpeningAndBeforeClosingEmptyBraces (#45514)" (#45682)

This reverts commit 076f22b.
BobobUnicorn pushed a commit to BobobUnicorn/TypeScript that referenced this pull request Oct 24, 2021
…abled insertSpaceAfterOpeningAndBeforeClosingEmptyBraces (microsoft#45514)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VS Code removes spaces between empty object literals even if insertSpaceAfterOpeningAndBeforeClosingEmptyBraces is true
3 participants