Skip to content
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

Fix #7920 - do not add comma for explicit inexact object with indexer property #7923

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions changelog_unreleased/flow/pr-7923.md
@@ -0,0 +1,52 @@
#### Do not add comma for explicit inexact object with indexer property or no properties ([#7923](https://github.com/prettier/prettier/pull/7923) by [@DmitryGonchar](https://github.com/DmitryGonchar))

<!-- prettier-ignore -->
```jsx
// Input
type T = {
a: number,
...,
}

type T = {
[string]: number,
...,
}

type T = {
// comment
...,
}

// Prettier stable
type T = {
a: number,
...
}

type T = {
[string]: number,
...,
}

type T = {
// comment
...,
}

// Prettier master
type T = {
a: number,
...
}

type T = {
[string]: number,
...
}

type T = {
// comment
...
}
```
10 changes: 5 additions & 5 deletions src/language-js/printer-estree.js
Expand Up @@ -1416,11 +1416,11 @@ function printPathNoParens(path, options, print, args) {
const lastElem = getLast(n[propertiesField]);

const canHaveTrailingSeparator = !(
lastElem &&
(lastElem.type === "RestProperty" ||
lastElem.type === "RestElement" ||
hasNodeIgnoreComment(lastElem) ||
n.inexact)
n.inexact ||
(lastElem &&
(lastElem.type === "RestProperty" ||
lastElem.type === "RestElement" ||
hasNodeIgnoreComment(lastElem)))
);

let content;
Expand Down