anchor.diff:                      | _ -> failwith "Invalid field option kind")
                   o))
   
  -    let Union _ (discr: string) (cases: (string * (string * string * (unit -> obj -> obj))[])[]) =
  +    let Union _ (discr: string) (cases: (string * (string * string * (unit -> obj -> obj) * OptionalFieldKind)[])[]) =
           box (fun () ->
               box (fun (x: obj) ->
                   if JS.TypeOf x ===. JS.Object then
  
positive.code:                                         Client-side JSON serialization does not support custom DateTime formatting. \
                                          This field will be serialized using ISO format."
                                          tt.FullName caseName argName)
                                  j + 1, fun es ->
                                      encode (T.FromType argT) >>= fun e ->
                                      k (J.NewArray [cString ("$" + string j); cString argName; e] :: es))
                              |> snd
                              <| []
                          | JI.InlineRecord(name, record) ->
  
negative.code:                     let tag = x?("$")
                      let tagName, fields = cases.[tag]
                      if JS.TypeOf discr = JS.Kind.String then o?(discr) <- tagName
                      fields |> Array.iter (fun (from, ``to``, enc, kind) ->
                          match from with
                          | null -> // inline record
                              let record = enc () (x?("$0"))
                              JS.ForEach record (fun f -> o?(f) <- record?(f); false)
                          | from -> // normal args
                              match kind with
                              | OptionalFieldKind.NotOption ->
                                  o?(``to``) <- enc () (x?(from))
                              | OptionalFieldKind.NormalOption ->
                                  match x?(from) with
                                  | Some x -> o?(``to``) <- enc () x
                                  | None -> ()
                              | _ -> failwith "Invalid field option kind")
                      o
                  else x // [<Constant>]
              ))
  