3

I know there are a number of projects which can compile F# to JavaScript. Does any of these projects support this use case:

  • developing an application in TypeScript
  • but writing part of the application in F#, as a library
  • consuming this F# library from the main TypeScript application, optimally in a type-safe way?
wmeyer
  • 3,426
  • 1
  • 18
  • 26

2 Answers2

2

WebSharper produces d.ts files for the compiled JS files. You can read about this in the relevant section of the documentation. However this feature is still experimental and uses an older version of TypeScript.

qwe2
  • 495
  • 3
  • 11
  • Thanks, that looks interesting! I think `t.ds` files generated for 1.4 should also be compatible with newer TypeScript versions. – wmeyer Nov 12 '15 at 08:53
1

There is FunScript (https://github.com/ZachBray/FunScript) but it does not seem to be widespread, so it may take you more time than the benefits are.

MartyIX
  • 27,828
  • 29
  • 136
  • 207
  • Thanks for the suggestion. However, it looks like FunScript is not designed for this use case: http://stackoverflow.com/a/19260214/79795 – wmeyer Nov 08 '15 at 17:36
  • I see. Well, from what I know about transcompilation, I don't think you will find anything useful because results of transcompilations are not typically human-friendly. I would just convert F# code to JS by a tool and I would write some TypeScript code that uses the JS code as an external module (you can generate [a TypeScript definition file](https://typescript.codeplex.com/wikipage?title=Writing%20Definition%20%28.d.ts%29%20Files) for the JS code though to get type control). I would definitely not try to adjust the generated JS code. – MartyIX Nov 08 '15 at 18:49