When using function alias and generic parameters the generated JavaScript is not generated and called consistently.

This is a minimal reproduction from a larger example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
open WebSharper.JavaScript

[<ReflectedDefinition>]
module Client =

    type ('species) t when 'species:equality = { reactants:'species list }
    type t_noparam = { reactants2: string list }

    let create reactants = { reactants = reactants }
    let create_no_type_param reactants = { reactants2 = reactants }

    let aliased_to = create
    let aliased_to_no_type_param = create_no_type_param

    let res = aliased_to_no_type_param []

    Console.Log res //Doesn't get this far

    let res2 :t<string> = aliased_to [] //Fails to initialise Uncaught TypeError: Cannot read property 'GetEnumerator' of undefined

    Console.Log res2

Depending how it's called you'll get something like

1
Uncaught TypeError: Client.aliased_to(...) is not a function

The generated JavaScript shows the issue

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    aliased_to:function(reactants)
    {
     return Client.create(reactants);
    },

    aliased_to_no_type_param:Runtime.Field(function()
    {
     return function(reactants)
     {
      return Client.create_no_type_param(reactants);
     };
    }),

    create:function(reactants)
    {
     return{
      reactants:reactants
     };
    },

    create_no_type_param:function(reactants)
    {
     return{
      reactants2:reactants
     };
    },

With a mismatch in the amount of function wrapping.

  • github

    I'm experiencing the same problem, is this going to be fixed in one of the upcoming releases?

  • JankoA

    Hi, this is working correctly in 4.0-beta, we will look into if this is solvable by quick fix in 3.x