Skip to content
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

Inconsistency between Js output for the optional field record #65

Open
mununki opened this issue Nov 19, 2023 · 1 comment
Open

Inconsistency between Js output for the optional field record #65

mununki opened this issue Nov 19, 2023 · 1 comment

Comments

@mununki
Copy link
Member

mununki commented Nov 19, 2023

@spice
type tOp = {
  label: option<string>,
  value?: int,
}

let sample2 = Js.Dict.empty()
sample2->Js.Dict.set("label", Js.Json.string("sample"))
let sampleJson2 = sample2->Js.Json.object_

let sampleRecord2: Records.tOp = {
  label: Some("sample"),
}

let encoded = sampleRecord2->Records.tOp_encode
t->testEqual(`encode omit optional field`, encoded, sampleJson2) // ok

let decoded = sampleJson2->Records.tOp_decode
t->testEqual(`decode omit optional field`, decoded, Ok(sampleRecord2))
// { TAG: 'Ok', _0: { label: 'sample', value: undefined } } { TAG: 'Ok', _0: { label: 'sample' } }
@mununki
Copy link
Member Author

mununki commented Nov 19, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant