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

Support record spreads in inline records #6326

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

zth
Copy link
Collaborator

@zth zth commented Jul 10, 2023

This allows you to use record spreads in inline records. It's mostly for consistency, record spreads are less useful in inline records because you can't get a hold of the type and coerce it to the underlying type definition. But, it's still useful to be able to spread into the inline record so you can share type definitions.

There's currently an outstanding parser issue I'd like to tackle in this PR as well. The issue is that you can't have just a single spread as the full inline record body. That would be useful to have. One example (that now doesn't parse) of a use case is this:

// Directive nodes can appear both standalone and as part of the ast variant

// Simplified type definition just for examplifying
type directiveNode = {
  name: string,
  loc: Location.t,
  payload?: payload
}

// directiveNode can appear both as 
@tag("kind") type astNode = ObjectNode({ name: string, directives: array<directiveNode> }) | DirectiveNode({...directiveNode})

@zth zth mentioned this pull request Jul 16, 2023
6 tasks
@zth zth requested a review from cristianoc July 30, 2023 19:29
@zth zth marked this pull request as ready for review July 30, 2023 19:29
@zth zth changed the title [WIP] support record spreads in inline records Support record spreads in inline records Jul 30, 2023
@zth zth force-pushed the inline-record-spreads branch 2 times, most recently from 8c40be7 to eec78ab Compare July 31, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant