As far as I know, the current F # compiler cannot create the WINMD component (mentioned by Denis), so you cannot call F # code directly from JavaScript. Perhaps it is possible (but I'm not sure!) To create the F # library as a portable library and link to it from a C # project compiled as a WINMD component, and then reference it using JavaScript. This adds an extra step, so it can be a little inconvenient.
Please submit this as a review of Visual Studio UserVoice . This will most likely be added if more people vote, clearly say that this is an important scenario for them!
Alternatively, as mentioned in Ramon, there are tools that translate F # to JavaScript and allow you to run your F # code as JavaScript (and call it directly from JS):
- WebSharper is a commercial, supported, open source product under the AGPL license.
- FunScript is a recent open source community community available in Apache 2.0
I have experience with FunScript (which works very well and has some nice features), but WebSharper works longer, so I believe it is more durable. It also adds a more sophisticated GUI infrastructure based on formlets (and similar patterns), while FunScript simply provides secure access to jQuery through a type provider that imports TypeScript definitions.
source share