ts2fable
raw JSON → 0.7.1 verified Fri May 01 auth: no javascript
A TypeScript definition file parser for the Fable compiler, converting TypeScript type definitions (.d.ts) into F# (.fs) files for use in Fable projects. Current stable version is 0.7.1, with releases on a quarterly to biannual cadence. It handles TypeScript modules, types, and interfaces, generating idiomatic F# bindings with support for generics, callbacks, and unions. Key differentiators: integrates with Fable's type system, supports modern TypeScript features, and includes a command-line interface for batch processing.
Common errors
error Error: undefined is not iterable ↓
cause Bug in ts2fable 0.7.0 when parsing certain TypeScript files with nested constructs.
fix
Update to ts2fable 0.7.1 or later.
error Option has no value ↓
cause Missing required command-line argument or incorrect input file path.
fix
Ensure the input .d.ts file exists and is accessible; use --help to check required arguments.
error Cannot find module 'typescript' ↓
cause The typescript peer dependency is not installed.
fix
Run
npm install typescript in the same directory where ts2fable is installed. Warnings
breaking Version 0.7.0 removed the Yargs dependency and changed some command-line options. ↓
fix Use new CLI arguments; check --help for updated options.
breaking Version 0.6.0 introduced Fable.Core 3.0 support, breaking compatibility with Fable.Core 2.x generated bindings. ↓
fix Regenerate bindings with ts2fable 0.6.0 or later, and update Fable.Core dependency.
deprecated The global installation via -g is deprecated; prefer using npx to ensure you use the latest version. ↓
fix Use `npx ts2fable` instead of global install.
gotcha Error: undefined is not iterable - occurs with some V8 TypeScript definitions. ↓
fix Upgrade to 0.7.1 which fixes issue #334.
gotcha Generated F# modules may have incorrect PascalCase naming if the TypeScript module name contains uppercase letters like 'BABYLON'. ↓
fix Upgrade to 0.7.0 or later which fixes this naming issue (#299).
Install
npm install ts2fable yarn add ts2fable pnpm add ts2fable Imports
- ts2fable wrong
npm install ts2fablecorrectnpm install -g ts2fable - default wrong
ts2fable input.d.ts > output.fscorrectnpx ts2fable input.d.ts output.fs - CLI usage
ts2fable --help
Quickstart
npx ts2fable https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/lodash/index.d.ts lodash.fs