Fable icon indicating copy to clipboard operation
Fable copied to clipboard

Fable generates javascript that throws an exception in the browser

Open klofberg opened this issue 11 months ago • 0 comments

Having a file named main.fsx with the following code and running dotnet fable:

type Model = unit

let update (model: Model) =
    model, ()

update ()

the fable compiler generates the following javascript:

export function update() {
    return [model, undefined];
}

update();

Running this code in the browser will throw an exception ReferenceError: model is not defined.

This is a problem for me in Elmish Land (https://elmish.land/docs/core-concepts/pages) where I scaffold elmish pages. The reason for the type alias for the Model is because I want to make it is easy for the user to extend the page.

I'm using fable compiler version 4.24.0 and dotnet version 9.0.101 on macos 15.0.

klofberg avatar Feb 10 '25 18:02 klofberg