type a = {
t ?: string,
l ?: int,
p ?: array<int>
}
type b = {
t ?: string,
l ?: string,
p ?: string
}
let intToString : option<int> => option<string> = (s) => {
switch s{
| Some(r) => Some("int")
| None => None
}
}
let arrayToString : option<array<int>> => option<string> = (s) => {
switch s{
| Some(r) => Some("array")
| None => None
}
}
let mapper: (a) => b = (a) => {
({ t : ?a.t
, l : ?a.l->intToString
, p : ?a.p->arrayToString
} : b)
}
let s = mapper({t : "Testing" })
Above line is giving this output { t : "Testing", l : undefined, p : undefined }
but I wanted to get this output { t : "Testing" }
How to write code for this in rescript ?