WebSharper 4.5.9 released with F# anonymous record support

Andras Janko

Andras Janko

Feb 26, 2019

Reading time:

2 mins

Share via:

WebSharper 4.5.9 is now available on NuGet, and as a vsix installer on the WebSharper website.

It contains client-side support for F# anonymous records, and a minor new UI templating feature.

Documentation: WebSharper 4.x for C# and WebSharper 4.x for F#.

The release notes are also found on GitHub.

See associated WebSharper.UI release notes here.


  • Assembly version mismatch in package WebSharper.FSharp, causing build fauilures.


  • Added client-side support for anonymous F# records.
  • UI Templating: add a new attribute ws-preserve. When an element is marked with this attribute, it and its children are not parsed for holes and ws-* attributes.

Anonymous records

F# anonymous records are now fully usable in client-side code. They are translated to plain JS objects:

let anon1 = {| A = 1 |} // translates to { A: 1 }

This gives a nice new alternative of constructing plain JS objects instead of New [ "A" => 1 ] or JS.Inline("{A: $0}", 1) or using a record/class type annotated with Prototype(false).

option<_> and voption<_> valued fields on anonymous records are automatically transformed to and from existing/missing JS properties:

let anon3 = {| A = Some 1; B = None |} // translates to { A: 1 }

This helps storing the values in minimal form, while keeping the full type safety of F# code.

See it live here:


Opt out of templating transformations

By default a ${Name} in a WebSharper.UI template file is treated as a hole to be filled. Including this verbatim is now made easier with new attribute ws-preserve that excludes children of current node from being interpreted for template holes and ws- attributes and nodes.

For example:

    <div ws-preserve>${ThisIsNotAHole}</div>

filled with:




Happy coding!

Read more from

Can’t find what you were looking for? Drop us a line.

Andras Janko
Found a typo?

This blog post is hosted on GitHub here. Feel free to file a ticket or send a PR.


We will not spam you or give your details to anyone.