-
Notifications
You must be signed in to change notification settings - Fork 6
Plans for optional records support #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi. I'm not aware of any syntax for conditionally setting an |
I'm assuming this has been answered adequately. But feel free to re-open if necessary. |
I'm facing this as well, when using the optional type foo = {
a: string,
b?: string,
}
let decoder = {
open Json.Decode
object(field => {
a: field.required(. "a", string),
b: field.optional(. "b", string),
})
} I think it would make more sense if let decoder = object(field => {
a: field.required(. "a", option(string)),
b: field.optional(. "b", string)
} |
According to the documentation, if you want to assign an option to an optional field, you need to prefix it with type foo = {
a: string,
b?: string,
}
let decoder = {
open Json.Decode
object(field => {
a: field.required(. "a", string),
b: ?field.optional(. "b", string),
})
}
Then it wouldn't be optional... You can get this behavior by using |
Ah man thanks, this is the syntax I didn't know existed! My suggestion was based off trying to get the types to agree on my own fork, you can disregard it :) |
Rescript v10 has implemented support for optional record fields
rescript-lang/rescript#5654
Any plans on implementing this instead of using Option?
Is it even feasible with the API. I might take a look at it myself if you think it is possible
The text was updated successfully, but these errors were encountered: