ocsigen/ts2ocaml
54.4
Weak · 24 September 2026
23.8k
lines of production code
F#
primary language
5
measurements over time
What this system is
This system is a TypeScript-to-OCaml/ReScript binding generator that converts TypeScript declaration files into native bindings for both OCaml (via JsOfOCaml) and ReScript. It provides a CLI tool that supports multiple generation presets and output configurations, enabling developers to integrate TypeScript types into functional programming environments. The tooling includes a F\#-based build system, comprehensive test suites for both OCaml and ReScript targets, and utilities for dependency analysis and code generation.
How it got here
2020–2021 — Build system migration and CLI refactoring
6 changes.
This period focused on modernizing the project's infrastructure by migrating the build system from Node.js to .NET/F\# and implementing a robust CLI using Yargs. The work also introduced granular code generation options for the JsOfOCaml target and established automated testing for the TypeScript-to-OCaml bindings.
2022–2023 — ReScript and TypeScript binding infrastructure
8 changes.
This period focused on establishing a robust infrastructure for generating F\# and ReScript bindings from TypeScript sources, including new build scripts and a ReScript code generation target. The work introduced core library modules for data structures and utilities, alongside updated bindings for the TypeScript compiler API and environment detection.
Features
Add Fable bindings for TypeScript, Chalk, and environment detection
New F\# bindings have been added to the lib/Bindings directory to expose the TypeScript compiler API, the Chalk terminal colorization library, and the browser-or-node environment detection library. The TypeScript bindings provide access to the full compiler API, including syntax tree traversal, diagnostics, and JSDoc parsing. The Chalk bindings expose the library's API for styling terminal text with colors and styles. The BrowserOrNode module provides functions to detect whether the code is running in a browser, Web Worker, Node.js, JsDom, or Deno environment.
lib/Bindings · high confidence
Add ReScript code generation target
Introduces a new ReScript target that generates .res and .resi binding files from TypeScript sources. The implementation includes configuration options for module systems (ES, CJS, default), output directories, and subtyping strategies (tagged or cast-function). It supports presets (minimal, safe, full) that automatically configure simplification and subtyping behaviors, and allows users to generate interface files alongside implementation files.
src/Targets/ReScript · high confidence
Add build infrastructure and update CLI output for ts2ocaml
The project now includes a comprehensive build system for the CLI, featuring a \fake\ script and \global.json\ to manage .NET 6 tooling. The webpack configuration has been updated to output \ts2ocaml.js\ to a \dist/js\ directory with a Node.js shebang header, and external dependencies like \typescript\ and \yargs\ are explicitly excluded from the bundle. Additionally, the repository now contains a \ts2ocaml.opam\ file defining dependencies on \dune\ 3.0, \ocaml\ 4.08, \gen\_js\_api\ 1.1.0, and \js\_of\_ocaml-compiler\ 4.0.0, alongside updated \.gitignore\ and \README.md\ documentation.
(repo-wide) · high confidence
Added graph and trie data structures for dependency analysis
The lib/DataTypes area now includes new functional data structures to support dependency analysis. A Graph module provides graph operations including topological sorting and strongly connected components (SCC) calculation, which are used to detect recursive dependencies. A Trie module implements a generic trie structure with support for union, path collection, and sequence conversion, alongside a specialized WeakTrie. These structures enable the system to map references between modules and identify circular dependencies.
lib/DataTypes · high confidence
Introduces new CLI options for code generation and output control
The JsOfOCaml target now supports several new command-line options that allow users to control how TypeScript is translated into OCaml. A \--preset\ option (Minimal, Safe, Full) provides pre-configured sets of generation rules. Users can now specify an \--output-dir\ to place generated bindings in a specific directory, and a \--stub-file\ to define the name of the JS stub file. Additionally, new flags allow for more granular control over the output: \--subtyping\ (Tag, CastFunction, Off), \--rec-module\ (Optimized, Naive, Off, Default), \--simplify\ (All, ImmediateInstance, ImmediateConstructor, etc.), and \--functor\ (On, Off, ForceInline). These options give users the ability to optimize the generated code for size, performance, or readability.
src/Targets/JsOfOCaml · high confidence
New build infrastructure for TypeScript binding generation
The build system now includes dedicated scripts and targets for generating F\# and ReScript bindings from TypeScript declaration files. A new \BindingUpdater.fs\ module and updated \build.fs\ script automate the conversion of TypeScript \.d.ts\ files into F\# and ReScript code, supporting both JSOO and ReScript test targets with various presets and options.
build · high confidence
Architecture
Migrate lib to core library with new helper modules
The lib directory has been restructured into a new core library, introducing dedicated modules for common types (ILogger, IContext), extension functions (string, list, map utilities), JavaScript interop helpers (package.json parsing, module name inference), naming conventions (case conversion), and parser/typer contexts. This refactoring separates concerns by providing reusable helpers for TypeScript parsing, type inference, and JavaScript binding, enabling cleaner integration with the core library.
lib · high confidence
Behavioural changes
Replace custom CLI argument parsing with Yargs
The tool's command-line interface has been refactored to use the Yargs library for parsing arguments, replacing the previous custom implementation. This change introduces structured command-line options for configuration files, verbose logging, and target selection (e.g., JsOfOCaml, ReScript), providing a more robust and standard way to configure the tool's behavior.
src · high confidence
Updated ReScript standard library to use @rescript/core
The ReScript-based standard library in the dist/res directory has been updated to depend on @rescript/core, as shown in the new rescript.json configuration. This change aligns the ReScript build with the latest ReScript v11 beta tooling, ensuring compatibility with the updated compiler and its associated core libraries.
dist · medium confidence
Updated TypeScript-to-OCaml bindings for new primitive and union types
The generated bindings in dist/res/src/ts2ocaml.res have been updated to use the RescriptCore module instead of the legacy Js module. This change introduces support for unboxed types, including new definitions for never, any, and unknown, as well as expanded Union and Intersection modules that handle up to eight cases. Additionally, the Primitive module now includes a comprehensive cases type covering all JavaScript primitives (null, undefined, string, number, boolean, symbol, bigint) with corresponding conversion and classification helpers.
dist/res · medium confidence
Test coverage
Added Jsoo test suite for TypeScript-to-OCaml bindings; Added ReScript test project with TypeScript interop; Added parser test target.
Dependencies
Migrate build system to F\# and update dependencies
The project's build system has been migrated from a JavaScript/Node.js-based setup to a .NET/F\#-based build using FAKE (build/build.fsproj). The main application logic is now compiled from F\# (src/ts2ocaml.fsproj), which references the shared library (lib/ts2ocaml.fsproj, formerly src/App.fsproj). Additionally, the project's npm dependencies have been significantly updated, including upgrading TypeScript to 5.4.2 and adding various type definitions and dev dependencies like @babel/core and webpack.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 57 → 54 (-2.8)
- Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 87 → 88 (+1.7)
- Architecture 100 → 100 (-0.1)
- Maturity 51 → 39 (-12.4)
- Readiness 56 → 70 (+14.1)
- Security 53 → 57 (+3.6)
Resolved (100)
- Coverage not included — suite not readable by the collector
- Critical CVE: [GHSA redacted] (yarn.lock)
- Dependency hygiene not measured — no packages were read
- Duplicated block (10 lines × 2) (lib/Bindings/TypeScript.fs)
- Duplicated block (10 lines × 2) (lib/DataTypes/Trie.fs)
- Duplicated block (10 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (10 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (10 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (10 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (10 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (11 lines × 2) (src/Targets/ReScript/Common.fs)
- Duplicated block (11 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (12 lines × 2) (src/Targets/ReScript/Common.fs)
- Duplicated block (12 lines × 2) (src/Targets/ReScript/Common.fs)
- Duplicated block (12 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (12 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (13 lines × 2) (lib/Bindings/TypeScript.fs)
- Duplicated block (13 lines × 2) (src/Targets/ReScript/Writer.fs)
- Duplicated block (16 lines × 2) (lib/Bindings/TypeScript.fs)
- Duplicated block (17 lines × 2) (src/Targets/ReScript/Common.fs)
- …and 80 more
New (47)
- Coverage not measured — no coverage collector is wired up
- Critical CVE: [GHSA redacted] (yarn.lock)
- Documentation: no architecture or design documentation (docs/rescript.md)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- End-of-life runtime: .NET net6.0
- FileTooLong: Bindings/TypeScript.fs (lib/Bindings/TypeScript.fs)
- FileTooLong: JsOfOCaml/Writer.fs (src/Targets/JsOfOCaml/Writer.fs)
- FileTooLong: ReScript/Writer.fs (src/Targets/ReScript/Writer.fs)
- FileTooLong: lib/Parser.fs (lib/Parser.fs)
- FileTooLong: lib/Syntax.fs (lib/Syntax.fs)
- FileTooLong: lib/Typer.fs (lib/Typer.fs)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High vulnerability: [GHSA redacted] (yarn.lock)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- …and 27 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
ocsigen/ts2ocaml was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 24 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 8e860e1a0b57d50c6d34f80af8fc5025ac0bf5d9 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-923689c465cf.