Skip to content

Drop emit of last semicolon in single-line object literal types #35042

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

Open
andrewbranch opened this issue Nov 11, 2019 · 3 comments
Open

Drop emit of last semicolon in single-line object literal types #35042

andrewbranch opened this issue Nov 11, 2019 · 3 comments
Assignees
Labels
Suggestion An idea for TypeScript
Milestone

Comments

@andrewbranch
Copy link
Member

Tracking follow-up to #33402

When synthetic object literal type nodes are printed on a single line, they come out like

type X = { a: string; b: string; };

While working on semicolon formatting features, I briefly had the formatter remove the semicolon after b: string;. The result was well-received but I ultimately decided the logic didn’t belong in the formatter; if this was going to be the canonical formatting of single-line object type literals, they should simply come out of the emitter that way.

@andrewbranch andrewbranch added the Suggestion An idea for TypeScript label Nov 11, 2019
@andrewbranch andrewbranch added this to the Backlog milestone Nov 11, 2019
@andrewbranch andrewbranch self-assigned this Nov 11, 2019
@fatcerberus
Copy link

Why semicolons? Why not just

type X = { a: string, b: string };

I only usually use semicolons in interfaces.

@andrewbranch
Copy link
Member Author

andrewbranch commented Nov 11, 2019

This is also how I write single-line object types. Honestly I’m a little worried that any change I make here will incite an angry mob composed of people with a particular lint rule. So I guess the answer to your question is “fear of public ridicule,” or more seriously, a preference not to shake things up for everyone without a good reason. Which is why I’m not totally confident that I will make this change at all.

@IllusionMH
Copy link
Contributor

IllusionMH commented Nov 15, 2019

Personally I'd prefer comma.
Prettier users will get their ; for free*

type X = { a: string, b: string };
// emitted as
type X = { a: string; b: string };

* for better or worse (definitely worse, because it will replace my ,)

@DanielRosenwasser DanielRosenwasser added Domain: Formatter The issue relates to the built-in formatter and removed Domain: Formatter The issue relates to the built-in formatter labels Nov 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants