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

Compiler doesn't prevent from spreading object types in a record type

Open tsnobip opened this issue 1 year ago • 1 comments

Originally discovered by a post on the forum, you can do this today:

type baseProps = {"name": string}

type props = {
  ...baseProps,
  label: string,
}

let label: props = {
  "name": "hello",
  "label": "label",
}

See playground

The compiler would not complain (tested with versions v11.0.0 to v11.1.1), type props here looks like a record type but is actually an object type.

tsnobip avatar Jun 20 '24 09:06 tsnobip

This issue 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 Jun 17 '25 02:06 github-actions[bot]

This is still the case.

fhammerschmidt avatar Jun 17 '25 08:06 fhammerschmidt