Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failure running WebSharper 4.0 tutorial

Tags:

f#

websharper

I am learning how to use WebSharper. Actually, I am failing to learn how to use WebSharper.

I wanted to learn how to build a simple SPA so I followed this tutorial from the WebSharper page. I am able to create the SPA with Visual Studio and Zafir (the codename for WebSharper 4.0 that is in beta). I followed every step in the tutorial. I have created a repo on github that is everything in the SPA.

The project won't build. More specifically, in the Client.fs file, I get compiler error

The value or constructor P is not found

in line 10 with the P, in line 11 the same error with the Div, and in line 18 I get the error

Namesapces cannot contain values.  Consider using a module to hold your value declrations.

with Run(), yet when I try to move the [<SPAEntryPoint>] information into the module HelloWorld, I get the error

Lookup on object of indeterminate type based on information prior to this program point.  A type annotation... 

As a result, when I try to build this project, the build fails.

Why am I getting these errors? Is the tutorial out of date with the rest of WebSharper? What can I do to get a simple tutorial to work correctly?

EDIT: I get the same errors when I use WebSharper v3.x, too.

like image 446
Steven Avatar asked Dec 20 '25 15:12

Steven


2 Answers

Although not mentioned in the tutorial, adding

open WebSharper.Html.Server

eliminated the compiler errors with P and Div, adding

open WebSharper.Html.Client

eliminated a new compiler error of OnClick, and moving the [<SPAEntryPoint>] into the module eliminated that compiler error and allowed me to build the project.

like image 98
Steven Avatar answered Dec 23 '25 04:12

Steven


Thanks for the report! I have updated documentation, indeed that page was not updated since a while. I will review it more thoroughly.

The source of the documentations are found at https://github.com/intellifactory/websharper.docs, feel free to add issue there about further questions/problems or also you can submit a PR.

like image 25
Jand Avatar answered Dec 23 '25 05:12

Jand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!