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

Typescript: Trailing comma on final parameter missing when ... used #4402

Closed
alantreadway opened this issue Apr 30, 2018 · 4 comments
Closed
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:duplicate Issues that are a duplicate of a previous issue

Comments

@alantreadway
Copy link

Prettier 1.12.1
Playground link

--parser typescript
--trailing-comma all

Input:

export function testFixture(
  {
    eventName = <'MODIFY'|'DELETE'> 'MODIFY',
    eventSourceARN = faker.internet.url(),
  } = {},
  ...records: {}[]
): Event {
  // Do some processing
}

Output:

export function testFixture(
  {
    eventName = <"MODIFY" | "DELETE">"MODIFY",
    eventSourceARN = faker.internet.url(),
  } = {},
  ...records: {}[]
): Event {
  // Do some processing
}

Expected behaviour:

export function testFixture(
  {
    eventName = <"MODIFY" | "DELETE">"MODIFY",
    eventSourceARN = faker.internet.url(),
  } = {},
  ...records: {}[],
): Event {
  // Do some processing
}
@duailibe
Copy link
Member

duailibe commented Apr 30, 2018

This is intended behavior, to align with the spec even though TypeScript allows it. Shouldn't make a difference since you can't have another argument after it anyway, you won't have any "diff issues" (which is the whole point of having trailing commas).

Duplicate of #3673

@duailibe duailibe added the lang:javascript Issues affecting JS label Apr 30, 2018
@bakkot
Copy link
Collaborator

bakkot commented Apr 30, 2018

(@duailibe, technically this is about function trailing commas, not object-rest-spread, but it's the same deal.)

Incidentally, TypeScript will disallow this syntax next time a release is cut from master.

@j-f1 j-f1 marked this as a duplicate of #3673 Apr 30, 2018
@duailibe
Copy link
Member

@bakkot Thank you, I had another issue opened, last minute I realized it was about objects and forgot to fix the link to the spec. I removed it anyways

@alantreadway
Copy link
Author

Thanks for the clarifications, SGTM if they are about to disable this in the compiler for TS 2.9

@alantreadway alantreadway changed the title Typescript: Trailing comma on final parameter missing when ... used with object destructuring Typescript: Trailing comma on final parameter missing when ... used May 1, 2018
@ikatyang ikatyang added the type:duplicate Issues that are a duplicate of a previous issue label May 1, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jul 30, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:duplicate Issues that are a duplicate of a previous issue
Projects
None yet
Development

No branches or pull requests

4 participants