Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

How to create a record value from a subtype record value?

$
0
0

The spread operator works only on record type creation, but not on record value creation.

This works:

type foo = {x: int, y: int}
type bar = {...foo, z: int}

But this is not supported:

let foo = {x: 1, y: 2}
let bar: bar = {...foo, z: 3}

I got this error message:
This has type: foo. But it's expected to have type: bar


Viewing all articles
Browse latest Browse all 2592

Trending Articles