rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Support record spreads in inline records

Open zth opened this issue 2 years ago • 2 comments

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 avatar Jul 10 '23 18:07 zth

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 07 '24 01:09 github-actions[bot]

This would be good to have, but might be worth just starting over.

zth avatar Sep 07 '24 05:09 zth

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 03 '25 02:09 github-actions[bot]

Will need to be redone if still relevant.

zth avatar Sep 03 '25 06:09 zth