On the server side, ==. always returns Unchecked.defaultof<bool>, ie. false. In JavaScript, as you noted, x == undefined returns true iff x === null || x === undefined. So I think the best way to implement ofNull for both client and server-side is probably to combine both your solutions:

1
2
3
4
module Option =
    let ofNull = function
        | null -> None
        | x -> if x ==. JavaScript.Undefined then None else Some x

I will investigate however why the simple null -> None | x -> Some x doesn't function as expected, it looks like the semantics might need some clarification.

By on 11/19/2014 2:19 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper