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
Don't add trailing comma in object rest spread #3313
Conversation
I'm still not sure what we should do here since the
and the trailing comma is valid in TypeScript. And if the new TS/JS spec allowed more trailing comma cases, how should we deal with it? EDIT: maybe more |
I'm not opposed to leaving it as is, in that case we should add to arrays and functions.. it's inconsistent right now. I'm not sure the added complexity is worth though (checking the options + checking the parser) because they're not useful at all in those cases IMO. EDIT: I understand your point now.. I guess the
Don't forget about flow! |
Although leaving this comma would be strictly correct considering "apply wherever possible", I think it wouldn't add much value and we can reason about new cases separately if/when they appear. |
Since the three trailing comma cases below are all valid TypeScript and we didn't print trailing commas for two of them, removing the trailing comma in the last case should be fine and more consistent. Prettier 1.8.2 --parser typescript
--trailing-comma all Input: const [
longKeySoThisWillGoOnMultipleLines,
longKeySoThisWillGoOnMultipleLines2,
longKeySoThisWillGoOnMultipleLines3,
...rest,
] = something;
const {
longKeySoThisWillGoOnMultipleLines,
longKeySoThisWillGoOnMultipleLines2,
longKeySoThisWillGoOnMultipleLines3,
...rest,
} = something;
function func(
longKeySoThisWillGoOnMultipleLines,
longKeySoThisWillGoOnMultipleLines2,
longKeySoThisWillGoOnMultipleLines3,
...rest,
) {
// something
} Output: const [
longKeySoThisWillGoOnMultipleLines,
longKeySoThisWillGoOnMultipleLines2,
longKeySoThisWillGoOnMultipleLines3,
...rest
] = something;
const {
longKeySoThisWillGoOnMultipleLines,
longKeySoThisWillGoOnMultipleLines2,
longKeySoThisWillGoOnMultipleLines3,
...rest,
} = something;
function func(
longKeySoThisWillGoOnMultipleLines,
longKeySoThisWillGoOnMultipleLines2,
longKeySoThisWillGoOnMultipleLines3,
...rest
) {
// something
} |
* master: Don't add trailing comma after object rest spread in TypeScript (prettier#3313) fix(cli): respect `--ignore-path` when using `--stdin-filepath` (prettier#3309) Fix infinite recursion in playground (prettier#3305) chore: setup markdown formatting (prettier#3224)
Running `yarn format` after updating results in changes to Mailto and Sms components as a result of prettier/prettier#3313 being shipped in Prettier v1.9.
Running `yarn format` after updating results in changes to Mailto and Sms components as a result of prettier/prettier#3313 being shipped in Prettier v1.9.
Running `yarn format` after updating results in changes to Mailto and Sms components as a result of prettier/prettier#3313 being shipped in Prettier v1.9.
For some reason the rest property in objects in typescript is a
ExperimentalRestProperty
node in the AST and we were not checking for it when printing trailing commas in object expressions.Fixes #3311