Search code examples
f#typescripttype-providersfunscript

FunScript: How to access TypeScript.Api<...>


I'm getting started with FunScript with a working example. Using Nuget to add the needed libraries, it works well.

In watching a 2013 video on channel9, they are making use of TypeScript.Api<...> to load types from typescript definition files.

I'm however unable to find this type provider anywhere. Where is it located? I realized that a good number of the type definitions have been compiled into libraries and available on nuget but I can't really use this since some of the code will be local typescript definition files.

The questions therefore are

  1. Where is the TypeScript.Api<...> type provider?
  2. If it is not available or the best way to use typescript definition, what other options exists.

Solution

  • As Thomas said, the type provider was removed mainly because it couldn't generate generic types, but the idea is to bring it back at some point.

    For the moment, though not ideal, you can generate your own bindings following these steps.

    1. Download or clone Funscript repository

    git clone https://github.com/ZachBray/FunScript

    1. Build the project

    cd FunScript build.cmd

    1. This needs to be improved but for now you need to zip the .d.ts files you want to convert and then:

    cd build\TypeScript bin\FunScript.TypeScript.exe C:\Path\to\typedefinitions.zip cd Output

    Please note the first time you build the definitions it may take several minutes. Once it's done in the output folder you'll find the compiled .dll libraries with the bindings.

    Also, while you're at it. It's better if you use the FunScript version you just build into build\main\bin, as it will probably be more updated than the nuget package.

    Good luck and have fun(script)!