[TypeScript] Trailing commas from type exports removed
See original GitHub issuePrettier 1.16.4 Playground link
--parser typescript
--trailing-comma all
Input:
export type TupleType = [
number, // exitcode
]
Output:
export type TupleType = [
number // exitcode
];
Expected behavior: Keep input as-is
Note that using babel
, babel-flow
or flow
parser keeps the trailing comma
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
How to Allow Trailing Commas (Comma-Dangle) With ...
Allowing comma-dangle in TypeScript requires two configurations in your ESLint setup. At first, you must turn off ESLint's default comma-dangle ...
Read more >Trailing commas - JavaScript - MDN Web Docs
JavaScript allows trailing commas wherever a comma-separated list of values is accepted and more values may be expected after the last item.
Read more >Trailing commas should not be used
Trailing commas should not be used ... Most browsers parse and discard a meaningless, trailing comma. Unfortunately, that's not the case for Internet...
Read more >Add formatting options to insert/remove trailing commas in ...
Add formatting options to insert/remove trailing commas in Object Literals, Function Declaration Parameters, Function Call Arguments, ES6 Imports/Exports.
Read more >Single type parameter T should have a trailing comma. ...
You don't need the trailing comma if you're not writing TSX (TypeScript + JSX). You do need it if you are. And if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Eksapsy I’m not sure, it just somehow stopped adding commas without me changing configuration or versions. For what it’s worth, I’m using eslint, and I can share my
.eslintrc
file 😃Oh thank you very much @rista404 . I use tslint though and I find it hard to believe that it would fix the problem itself 😛 I very much appreciate the effort though! 😄
I short of “fixed” it by just using an interface instead of having a type declaration right away. Like this:
Before
After
The problem is potentially that prettier thinks that type declaration inside a generic shouldn’t have commas at all. So, it’s not “fully compatible” with Typescript in some way probably, but I wont jump to conclusions.