How to convert record to object?

For example, Simply convert record:
{name: “John”, age:20}
to obj:
{“name”: “John”, “age”:20}

And how to get a subset of an object, like on get:
{“name”: “John”}
from above.

Also, is there a Rescript version of Partial<'t>?

Could you elaborate on the reason, why you want to convert a record to an object?

With the upcoming release of rescript v11 you can use “type coercion operator” :> to reduce a record type to a subset of it like this:

type a = {x: int}

type b = {
  ...a,
  y: bool,
}

let f: a => int = a => a.x

let recordA: a = {x: 3}
let recordB: b = {x: 42, y: true}

let works = recordA->f
// let fails = recordB->f

let success = (recordB :> a)->f

example at the playground

Edit: thanks to @flo-pereira, I updated the example to what I wanted to show and fixed my oversight. Coercing a record of type a to a doesn’t really make sense and the formatter even had removed it entirely from the example. I wanted to show, how to coerce a record of type b to type a.

let success = (recordB :> a)->f