You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On several occasions, I've want to map a parameter as Option<&JsValue> or a return type as Option<JsValue>, just to indicate explicitly that it is optional. I realize JsValue supports null & undefined.
Proposed Solution
Implement the trait.
Alternatives
I think of JsValue as the TypeScript any type. TypeScript also has the non-primitive object type that does not support null or undefined, but everything else. May be it would be better to add that so it makes more sense to have a Options<JsSome> or something like that.
The text was updated successfully, but these errors were encountered:
The reason we haven't implemented this is that there's no way to distinguish between Some(null) and None in JS, so there's no way to losslessly represent the value in JS. We've currently been requiring that Rust opts-in to .unwrap_or(...) or something like that.
Motivation
On several occasions, I've want to map a parameter as
Option<&JsValue>
or a return type asOption<JsValue>
, just to indicate explicitly that it is optional. I realize JsValue supports null & undefined.Proposed Solution
Implement the trait.
Alternatives
I think of
JsValue
as the TypeScriptany
type. TypeScript also has the non-primitive object type that does not support null or undefined, but everything else. May be it would be better to add that so it makes more sense to have aOptions<JsSome>
or something like that.The text was updated successfully, but these errors were encountered: