Skip to content

From .d.ts to F#

Glutinum reads the TypeScript declarations of a JavaScript package and writes the F# binding for it. Fable compiles your F# against that binding, and the JavaScript library runs unchanged.

Try it in the browser Get started View on GitHub

Terminal
npm install date-fns
npx @glutinum/cli date-fns --out-file Glutinum.DateFns.fs

One command per package

Name an installed package and Glutinum finds its declarations, follows the packages they depend on, and writes one F# file. A single .d.ts file works too.

Program.fs
open Glutinum.DateFns
open type Glutinum.Types.TypeScript.Exports

let today = Date.Create(2026, 8, 17)
let later = DateFns.addDays (today, 7)

printfn "%s" (DateFns.format (later, "yyyy-MM-dd"))

Members, not dictionaries

Interfaces become F# interfaces, classes get a constructor in Exports, functions become static members with the right overloads.

Unions, not obj

Literal unions become string enums you can match on. Mixed unions become erased unions with named cases, or U2 to U9.

Shared packages, not copies

Every binding references Glutinum.Types for the ES library types, plus Glutinum.Web for the DOM or Glutinum.Node for the Node API. None of it is copied into your file.

Honest about the gaps

What TypeScript can express and F# cannot becomes obj, and the limitations page says which constructs those are.

Start with a package you already use

Read the guide