Skip to content

Record type spreads in inline records does not work if there's only a spread #6520

Closed as not planned
@zth

Description

@zth
type x = {name: string}

type y = Person({...x})

Gives:

I'm not sure what to parse here when looking at ")".

Add a field before and it parses fine:

type x = {name: string}

type y = Person({age: int, ...x})

Add a field after and it tries to parse the spread as an object:

type x = {name: string}

type y = Person({...x, age: int})
A record type declaration doesn't support the ... spread. Only an object (with quoted field names) does.

So, this is ambiguous with regular object spreads. But previously we've changed things up to prefer records now that records are so much more powerful, and there are less reasons to use regular objects. So it'd be safe to parse this as a record spread instead of an object spread, in my opinion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleOld issues that went stalesyntax

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions