This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
ts2fable with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Install it with npm and run the
ts2fable command on a TypeScript declaration file.
npm install -g ts2fable ts2fable react.d.ts
The parser just displays the results on screen, but you can redirect the output to a file:
ts2fable react.d.ts > Fable.Import.React.fs
Globals. For example:
module ReactDom = type [<Import("react-dom")>] Globals = static member render(element: DOMElement<'P>, container: Element, ?callback: Func<Element, obj>): Element = jsNative
Importattribute is on the
Globalsvalue, not the module.
type CanvasRenderingContext2D = abstract fillStyle: U3<string, CanvasGradient, CanvasPattern> with get, set let ctx: CanvasRenderingContext2D = failwith "dummy" ctx.fillStyle <- U3.Case1 "#FF0000"
newkeyword. In the parsed files, interfaces with this capability will have a
type CanvasRenderingContext2DType = abstract prototype: CanvasRenderingContext2D with get, set [<Emit("new $0($1...)")>] abstract Create: unit -> CanvasRenderingContext2D
Invokemethod to callable interfaces:
type Express = inherit Application abstract version: string with get, set abstract application: obj with get, set [<Emit("$0($1...)")>] abstract Invoke: unit -> Application