By András Jankó on Friday, June 9, 2017 — 0 comments

WebSharper 4 beta-7 releasedCore team

WebSharper 4 beta now has F# 4.1 and C# 7 language support.

Latest Visual Studio template installers compatible with VS2015/2017 is available here.


  • #689 Added support for F# 4.1 and C# 7 new language features.
  • #596 Automatic download of remote web resources to serve from locally. Set <WebSharperDownloadResources>True</WebSharperDownloadResources> in your project file to have WebSharper download all remote js/css defined in current project and all references. Add <add key="UseDownloadedResources" value="True" /> to your <appSettings> section in web.config.
  • #696 Parameterless union cases of a JavaScript-annotated union translate to a singleton instance for performance. Equality checks are optimized for these cases to just check the tag.
  • #638 Added Warn attribute, calls to annotated member will generate a warning wherever it is called from client-side code.
  • #693 F# multi-type trait calls translate but still are not supporting overloads. F# + and - operators properly translate to the operator defined by the type.
  • #703 Stub classes with a base class do not emit a new class overwriting outside one.



  • #697 Union with Constant case will have no prototype implicitly (instance methods compiled to static)
  • #598 RPC signature hash computing is now platform-independent.
  • #702 C# conditional compilation symbols are properly respected for translation with WebSharper.
  • #705 JQuery is linked from https
By András Jankó on Wednesday, April 12, 2017 — 0 comments

WebSharper 4 beta-6 bugfix releasedCore team

Zafir. Is now available on NuGet, .vsix installers at WebSharper downloads ("Other versions" section).

Thanks to @cgravill and @amieres for submitting bug reports.

See this release on GitHub.


  • #681 Return was missing so infinite loop was generated on a module-level let rec returning unit
  • #682 Mark arguments transformed in tail recursion optimization as mutable to avoid incorrect inlining which could result in invalid JS code
  • #680 Do not eta-reduce to expressions that has side effects so needs the closure
  • #666 Ignore duplicate references when initializing Sitelets in non-ASP.NET contexts, fail only on WS assemblies with different versions.
  • #684 Fix for JavaScript statements in Inline to not drop first statement if it was an expression
  • #685 Different Name and AssemblyName in F# does not cause errors


  • #683 You can now opt-out of dead code elimination for SPA projects. Use <WebSharperDeadCodeElimination>False</WebSharperDeadCodeElimination> in the project file or add --dce- to the wsfsc.exe command line.
  • #686 Case test for erased unions with a case which is a plain object in JS now compiles, if there is no previous case that is also a plain object, then it gives a more specific error

Breaking changes

  • #670 By default, classes (including F# records and unions) with no methods translated to JS instance methods and having no base class are now translated not to have a prototype. JSON serializer was fixed to handle this. This is a performance optimization, but disallows type checks or inheriting from a class like this. So a new attribute Prototype was added to opt-in for generating a prototype for the type in the translation. Extra features: Prototype(false) forces the type to have no prototype, converting instance methods to static in translation.
By András Jankó on Saturday, March 25, 2017 — 0 comments

WebSharper 4 beta-6 releasedCore team

WebSharper 4 beta-6 contains updates to DOM and JQuery bindings, erased union types, JS output optimizations and fixes.

Visual Studio 2017, F# 4.1 and C# 7 support are coming soon.


  • using FSharp.Compiler.Service 11.0.4. To have optimal compilation speeds, go to a folder in a solution at packages\Zafir.FSharp.\tools and run ./runngen in PowerShell as administrator.
  • #650 Bindings to DOM have been updated to current ECMA specification
  • #652 Bindings to JQuery have benn updated to version 3.1.1
  • #660 Erased union and option types have been added to WebSharper.JavaScript namespace, named Union and Optional. These are similar to Choice and Option types of F#, but work as TypeScript's erased unions in the JS translation. Conversion functions are available under modules Optional and Union.
  • #651 output is using JavaScript strict mode
  • #550 custom structs can now be used in RPC calls
  • #644 F# unions with Constant null case can now be used in RPC calls
  • #642 Local generic functions in F# compile when the compiler does not need the type parameter for custom code generation (macros). If it does, you get an error "Macro name would use a local type parameter. Make the inner function non-generic or move it to module level and mark it with the Inline attribute"
  • #648 JavaScript code output optimizations:
    • Functions taking F# tupled or curried functions as parameters and only fully applying them (in the case of curried parameter) now translates to taking a flat JavaScript function. This means less closure creation and better performance when using functions like List.map2
    • Local F# tupled and curried functions are now converted to flat functions in JavaScript where possible
  • #649 Tail call optimization for F#:
    • let rec expressions with single or mutual recursion
    • Module or class (in default constructor) let rec expressions with single recursive function
    • Class members, calling itself but no other members of the same class annotated with JavaScript (so inlines do not opt-out of optimization). For instance members, the call must be on the current instance.
  • #655 Require and RemotingProvider attributes can take additional object parameters. These will be passed on to the constructors of the resource class and the client-side RemotingProvider instance respectively.
  • WebSharper.Resources.BaseResource is not an abstract class any more. This allows using it with the Require attribute without defining an extra type: ` fsharp [<Require(typeof<Resources.BaseResource>, "//myurl.com/mylib.js")>]`


  • #645 Name conflict in WebSharper.Sitelets.Content from C#
  • #657 Using Name attribute on properties with getter and setter now adds set_ to the name of the setter to disambiguate them.
  • #633 WIG-defined interfaces now can be inherited from with F#/C# code if they contain only method definitions without custom inline annotations. Calling interface members from .d.ts-based bindings now translate properly, but these interfaces can't be inherited from in your code (as they are using special call semantics).
  • #665 Unpacking Scripts/Contents for web projects required the WebProjectOutputDir property, although previously assumed project root as default. This default has been restored for back-compatibility.
  • #668 Printing F# compilation errors and warnings as compiling with fsc.exe would, respecting nowarn, warn, warnon, warneserror flags
  • #667 Fix C# analyzer giving failure warnings on build
  • #669 Async.StartImmediate and Async.StartWithContinuations now start the async immediately as in .NET, possibly finishing synchronously if they contain no bind/combine.
  • #671 Fix a translation bug in optimization around calling curried instance members
  • #673 integer type Parse and TryParse methods follow .NET semantics, checking boundaries and disallowing fractions
  • #677 Fix using Inline on constructors calling into other constructors
  • #678 Fix inlining JavaScript statements, and using return to produce a value
  • #679 exception properties Message and InnerException should work for all exception types
  • #676 Queue and Stack constructors taking a seq<'T> (IEnumerable<T>)

Breaking changes

  • Macro API: MacroResult.MacroNeedsResolvedTypeArg now needs the offending type parameter as a field. You can decide if a type is a type parameter of any kind by using the new IsParameter property.

By Kimserey Lam on Wednesday, March 1, 2017 — 0 comments

Create a simple form engine with WebSharper.UI.Next in F#Community

Create a simple form engine with WebSharper.UI.Next in F# WebSharper came out with WebSharper.Forms. It is a terse DSL to build form, I posted a tutorial on it few months ago https://kimsereyblog.blogspot.co.uk/2016/03/create-forms-with-websharperforms.html. It’s very powerful as the abstraction handles most of the scenarios. Today I would like to show anothe way to create forms by building a
>> Read the full article on kimsereyblog.blogspot.com
By Kimserey Lam on Thursday, February 23, 2017 — 0 comments

Post form data to WebSharper sitelet from HTML/JSCommunity

Post form data to WebSharper sitelet from HTML/JS When building websites, chances are that you will need to gather data from your users. The most common way to gather data is via a form. But after gathering the data, there are two ways to submit it from the browser to your server: Using a HTML form Using an Ajax call Today we will see the differences and how we can implement it. 1. Submit data
>> Read the full article on kimsereyblog.blogspot.com
By Kimserey Lam on Monday, February 13, 2017 — 0 comments

Use Local storage with ListModel with WebSharper.UI.Next in F#Community

Use JS local storage with ListModel with WebSharper UI.Next in F# Last week I wanted to use the browser local storage to store a list of elements. I wanted to update the resource split project to have the data stored (temporarily) so that it will be easier to add or remove resources. The browser local storage is ideal for this kind of scenario. Turns out WebSharper.UI.Next has the feature built
>> Read the full article on kimsereyblog.blogspot.com