Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to Fable.Lit 1.4.2 causes issues in Elmish types #72

Open
leolorenzoluis opened this issue Sep 27, 2022 · 1 comment
Open

Comments

@leolorenzoluis
Copy link
Member

leolorenzoluis commented Sep 27, 2022

I am testing with the Fable.LitRouter and LitState but it requires 1.4.2, I get compilation error if I get 1.4.2 but if I downgrade to 1.4.1 then there's no error. This is just showing in Jetbrain's Rider. If I compile with npm run start then there's no error.

Looking at the commit history/release notes there shouldn't be anything that should affect this in 1.4.2.

Screen Shot 2022-09-27 at 5 53 32 PM

Screen Shot 2022-09-27 at 5 56 47 PM

Looking at the release notes there shouldn't be any impact on the Elmish/Lit libs.

For reference this is the sample code that I tried and updating new variables to make it minimal


let initialState1() =
    let monitorPageModel, monitorPageMsg = ListMonitorsPage.init()
    let welcomePageModel, welcomePageMsg = WelcomePage.init()
    
    let model = { CurrentPage = Anonymous AnonymousPage.Welcome; ServerMessage = []; MonitorModel =  monitorPageModel; WelcomePageModel = welcomePageModel }
    model, Cmd.none
    
let update1 msg model =
    model, Cmd.none

let view1 model dispatch =
    html $"""
    <div>Hello world</div>
    """


Program.mkProgram initialState update view
|> Program.withLit "my-app"
|> Program.withBridgeConfig (Bridge.endpoint socketEndpoint |> Bridge.withMapping ServerMsg)
|> Program.run

Screen Shot 2022-09-27 at 5 57 51 PM

Update:

Looks like something in these two packages are causing the compiler to get confused.

<PackageReference Include="Fable.LitRouter" Version="1.0.0-beta-005" />
<PackageReference Include="Fable.LitStore" Version="1.0.0-beta-001" />

If I remove that and just keep Lit to 1.4.2 it has no compile error

I've narrowed it down. It's the Fable.LitRouter that's causing an issue. Not sure where the source code for LitRouter is?

I extracted the library and I don't get any errors, so not sure why this is happening?

I removed the Fable.LitRouter and just created a separate fs file from https://nuget.info/packages/Fable.LitRouter/1.0.0-beta-005 Maybe @JordanMarr knows?

@alfonsogarciacaro
Copy link
Member

Hmm, not sure what's the problem here but unfortunately we've seen similar issues in the past. This sometimes happens because of type inference in F#, we may do an "innocent" change to a function without type annotations and this may subtly break the signature without us noticing. Because Fable compiles from sources, the type inference in that case works, but in the IDE on when using dotnet build the problem may surface.

I'll try to investigate but in the meantime your solution of adding the source of Fable.LitRouter directly to your project should work. Hopefully publishing a new version of Fable.LitRouter that depends on Fable.Lit 1.4.2 should work too. Sorry for the hassle!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants