Closed
Description
Json.serializeExn
and Json.deserializeUnsafe
were introduced to allow string serialization of records that contain option
values.
E.g.
let user = {
name: "test",
age: None
}
would compile to { name: "test", age: undefined}
— a JS object that's not stringifiable due to the undefined
value (which is not part of the JSON spec).
This was particularly an issue in Next, when using specific features like SSR to inject initial props (see #4443 for the full discussion).
Now with our new @optional
feature (#5423) this is not needed anymore, since I would just declare a prop type as followed:
type user = {
name: string,
@optional age: int
}
Later on I'd just omit the age
and be good to go. No undefined
values in the output:
let user = {name: "patrick"}
// Equal to `{name: "patrick"}` in JS
My suggestion is to add a deprecation notice and point to the new docs of the @optional
feature instead. Any opinions?
Metadata
Metadata
Assignees
Labels
No labels