Skip to content

JSX spread operator syntax error on the flow parser #3898

Closed

Description

@vjeux

Prettier 1.10.2
Playground link

--parser flow

Input:

<JSX>
  {...edges}
</JSX>

Output:

SyntaxError: Unexpected token ... (2:4)
  1 | <JSX>
> 2 |   {...edges}
    |    ^^^
  3 | </JSX>

It works in babylon, so my guess is that we just need to upgrade flow and it should just go away.

Activity

  1. added
    lang:flow
    on Feb 6, 2018
  2. j-f1 commented on Feb 6, 2018

    @j-f1
    Member

    What does this even do? the Babel 6 REPL passes the spread through unchanged, even in ES5 mode. Babel can’t parse the result in standards mode, either.

  3. vjeux commented on Feb 6, 2018

    @vjeux
    ContributorAuthor

    I have some more context. In React currently we don't need to use ... because the type of a child in React is either an object or an array of objects. We're playing around with a version of React that doesn't handle arrays and you've got to manually spread in order to get the same behavior. We have a custom jsx transform step for it.

    It's unclear at this point if we are going to move forward with it but the latest version of both flow and babylon are parsing it so it shouldn't be a burden on prettier to print it.

  4. mroch commented on Feb 6, 2018

    @mroch

    react/jsx#57

    It's part of JSX now

  5. added
    locked-due-to-inactivity
    on Jul 5, 2018
  6. locked as resolved and limited conversation to collaborators on Jul 5, 2018
  7. added theissue type on Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:flowlocked-due-to-inactivity

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions