$ account ocsigen
ts2ocaml is a CLI tool that generates OCaml and ReScript bindings from TypeScript type definitions. It parses TypeScript AST using the TypeScript compiler API (via Fable), transforms the AST into a language-agnostic internal representation, resolves types (including generics, subtyping, unions, intersections), and emits target-specific code for js_of_ocaml (.mli) or ReScript (.res/.resi). The tool is implemented in F#, compiled to JavaScript via Fable, and distributed as an npm package. It supports multiple backends via a pluggable ITarget interface, includes a comprehensive type resolver (Typer), and provides utilities for naming, text manipulation (rope), trie-based data structures, and dependency graph analysis (topological sort, SCC). The repository also ships a minimal standard library for each target to support emitted bindings. It is actively maintained with CI, frequent releases, and documentation for modeling subtyping and development setup.