Skip to content

Fable generates javascript that throws an exception in the browser #4041

@klofberg

Description

@klofberg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions