You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.scope:externalThis is not an issue with Prettier, it’s an issue with external software, like an editor integrationtype:questionQuestions and support requests. Please use Stack Overflow for them, not the issue tracker.
Under certain difficult-to-predict circumstances, Prettier will add a trailing comma in TypeScript "binding patterns" (e.g. const [x, y] = [1, 2]) when --trailing-comma is es5 or all.
When this happens, TypeScript 2.9 will give the error "A rest parameter or binding pattern cannot have a trailing comma". This was a breaking change from 2.8 to 2.9.
Some related but slightly different issues: #3673#3311
I think I'm having a different issue with trailing commands, and I'm not sure if it's because of Prettier or TypeScript. Using Prettier 1.13 and TypeScript 2.9.1, Prettier adds a trailing comma after ButtonBaseClassKey and TypeScript errors with Trailing comma not allowed. It works if I remove the trailing comma option (defaults to none).
As a workaround for anyone who stumbles into this issue, you can just append // prettier-ignore to an offending line and Prettier will not add a trailing comma there to satisfy TS.
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.scope:externalThis is not an issue with Prettier, it’s an issue with external software, like an editor integrationtype:questionQuestions and support requests. Please use Stack Overflow for them, not the issue tracker.
Activity
ikatyang commentedon Jun 3, 2018
I think the trailing comma there should be allowed, tracked in microsoft/TypeScript#24628.
nickserv commentedon Jun 3, 2018
As far as I'm aware this is an intentional change in TypeScript, I doubt they'd change it back.
nickserv commentedon Jun 3, 2018
This is a bug in Prettier, here is the breaking change note from TypeScript:
https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#trailing-commas-not-allowed-on-rest-parameters
hawkrives commentedon Jun 3, 2018
@nickmccurdy IIRC, that's for rest patterns - e.g.,
is invalid, but
should still compile.
nickserv commentedon Jun 3, 2018
I see, that issue seems to be microsoft/TypeScript#24628.
I think I'm having a different issue with trailing commands, and I'm not sure if it's because of Prettier or TypeScript. Using Prettier 1.13 and TypeScript 2.9.1, Prettier adds a trailing comma after
ButtonBaseClassKeyand TypeScript errors withTrailing comma not allowed.It works if I remove the trailing comma option (defaults to none).duailibe commentedon Jun 4, 2018
@nickmccurdy Can you open a separate issue for that, please?
michaeljota commentedon Jun 5, 2018
The issue in TS seems to being closed after microsoft/TypeScript#24672 is merge. So, it was an issue with TS after all. 👍
ikatyang commentedon Jun 6, 2018
Fixed in microsoft/TypeScript#24672 thanks to @bakkot!
vaskevich commentedon Jun 8, 2018
As a workaround for anyone who stumbles into this issue, you can just append
// prettier-ignoreto an offending line and Prettier will not add a trailing comma there to satisfy TS.mscottx88 commentedon Jul 30, 2018
This also happens to object destructure statements with default values.
To follow up on @vaskevich response, here is a clear picture of what to do to make both prettier and tslint happy in this situation:
ikatyang commentedon Jul 30, 2018
FYI, TS 3.0 just got released.
prettier bug fixed: prettier/prettier#4624