anchor.diff:                                  if JS.HasOwnProperty x k then r := discr?(k); true else false)
                               !r
                       o?("$") <- tag
  -                    cases.[tag] |> snd |> Array.iter (fun (from, ``to``, dec) ->
  +                    cases.[tag] |> snd |> Array.iter (fun (from, ``to``, dec, kind) ->
                           match from with
                           | null -> // inline record
                               o?("$0") <- dec () x
                           | from -> // normal args
  -                            o?(from) <- dec () (x?(``to``)))
  +                            match kind with
  +                            | OptionalFieldKind.NotOption ->
  +                                o?(from) <- dec () (x?(``to``))
  +                            | OptionalFieldKind.NormalOption ->
  +                                o?(from) <-
  +                                    if JS.HasOwnProperty x ``to``
  +                                    then Some (dec () x?(``to``))
  +                                    else None
  +                            | _ -> failwith "Invalid field option kind")
                       o
                   else x // [<Constant>]
               ))
  
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>]
              ))
  