• Stars
    star
    160
  • Rank 226,219 (Top 5 %)
  • Language
    F#
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated 23 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate OCaml bindings from TypeScript definitions via the TypeScript compiler API

ts2ocaml

npm latest version npm latest version

Generate OCaml bindings from TypeScript definitions via the TypeScript compiler API.

Installation

Try out v2 beta!

npm install -g @ocsigen/ts2ocaml@beta

npm install -g @ocsigen/ts2ocaml

Or if you are using yarn:

yarn global add @ocsigen/ts2ocaml

An in-browser version may be available in future.

Overview

Goals:

  • Provide a way to quickly generate a missing binding to some JS package you need in your project.
    • This tool can generate OCaml bindings to JS packages from TS definition files (.d.ts), which you can use with minimal modification.
  • Help library authors by reducing the amount of boilerplate code they have to write by hand.
    • This tool can be configured to generate an imperfect but simpler version of bindings, which you can easily modify to create a better binding library.

Non-goals:

  • Generate a binding written in 100% OCaml-idiomatic way.
    • OCaml has very different programming concepts from TypeScript, so it's not very straightforward to translate TypeScript's concepts to OCaml's one.
    • This tool will simply generate bindings which closely resembles the original TypeScript definitions. It's human's job to translate it to OCaml-idiomatic API.
  • Perfectly replicate TypeScript's type system in OCaml.
    • Many of the advanced types in TypeScript, such as keyof T or T extends U ? A : B, are simply impossible to simulate in OCaml.
    • In those cases, this tool will leave them as untyped. It's also human's job to (possibly) restore type safety with some other means.

Documentation

For users:

For developers and contributors:

About this tool

This tool is heavily inspired by fable-compiler/ts2fable, which generates Fable (F# AltJS) bindings from TS definition files.

This tools is licensed under the Apache License 2.0.

More Repositories

1

js_of_ocaml

Compiler from OCaml to Javascript.
OCaml
932
star
2

lwt

OCaml promises and concurrent I/O
OCaml
682
star
3

eliom

Multi-tier framework for programming web and mobile applications in OCaml.
OCaml
294
star
4

tyxml

Build valid HTML and SVG documents
OCaml
161
star
5

ocsigenserver

Web server in OCaml.
OCaml
100
star
6

ocsigen-start

Ocsigen-start: Higher-level library to develop Web and mobile applications with users, (pre)registration, notifications, etc.
OCaml
74
star
7

reactiveData

Functional reactive programming with incremental changes in data structures
OCaml
52
star
8

macaque

OCaml
38
star
9

ocsigen-toolkit

User interface widgets for OCaml applications
OCaml
31
star
10

ts2ocaml-example

Example use of ts2ocaml
Makefile
17
star
11

obrowser

OCaml virtual machine written in Javascript.
OCaml
14
star
12

ojquery

jQuery Binding for Eliom.
OCaml
11
star
13

lwt_glib

GLib/GTK event loop for Lwt
OCaml
11
star
14

graffiti

A tiny collaborative drawing application in eliom.
OCaml
10
star
15

tutorial-deprecated

Deprecated. Please use repository tuto instead.
OCaml
10
star
16

tuto

Ocsigen tutorial
OCaml
10
star
17

ocaml-eliom

A modified OCaml compiler for eliom programs
OCaml
10
star
18

lwt_ssl

OpenSSL binding with concurrent I/O
OCaml
9
star
19

ocaml-indexeddb

OCaml binding for IndexedDB
OCaml
9
star
20

eliomlang

Runtime and tools for the eliom language
OCaml
9
star
21

resource-pooling

a derivative of Lwt_pool with extensions
OCaml
8
star
22

ocsimore

A wiki in Eliom.
OCaml
7
star
23

html_of_wiki

OCaml
6
star
24

ocsipersist

OCaml
6
star
25

wikidoc

Convert OCaml documentation to wiki.
OCaml
6
star
26

ocsipersist-legacy

An extension for ocsigen server to use a key/value store
OCaml
6
star
27

ocsigen.github.io

Ocsigen Web site
JavaScript
6
star
28

eliom-widgets

Widgets for client-server Web applications written with Eliom
OCaml
6
star
29

ocsigen-ppx-rpc

This PPX adds a syntax for RPCs for Eliom and Ocsigen Start
OCaml
6
star
30

ojwidgets

Widgets for browser applications written in OCaml (also see Eliom widgets)
OCaml
5
star
31

lwt_log

(Deprecated) Lwt-friendly logger
OCaml
4
star
32

old.ocsigen.org

The old http://ocsigen.org/ website.
OCaml
4
star
33

lwt_domain

Parallelism in Lwt using domainslib
OCaml
4
star
34

oclosure

Binding of the Google Closure Javascript library in OCaml using Js_of_ocaml.
JavaScript
4
star
35

ocsigen-widgets

Widgets for Web apps in OCaml (client only or client-server)
OCaml
3
star
36

ocsforge

Ocsforge is a project aiming at creating sites for project hosting (forges).
OCaml
2
star
37

docker-buildbot

Shell
2
star
38

ocsigen.org-data-deprecated

Ocsigen.org versioned data. DEPRECATED. The doc is now in each project (branch wikidoc)
JavaScript
2
star
39

.github

1
star
40

js_of_ocaml-ocamlbuild

OCaml
1
star
41

lwt_camlp4

(Deprecated) Camlp4 syntax for Lwt
OCaml
1
star
42

ocamlweb-roadmap

Roadmap for better Web and mobile developement tools in OCaml
1
star
43

pa_include

Include .mli as module signature.
OCaml
1
star
44

eliomlang-playground

A (perpetually broken) playground for a minimal webapp with eliomlang
Makefile
1
star
45

docker-ocsigen

A base Docker image for Ocsigen (with opam, eliom, js_of_ocaml and ocsigenserver installed)
Shell
1
star
46

ocsigen.org-deprecated

ocsigen.org site before 2019 (wiki format) DEPRECATED. Use https://github.com/ocsigen/ocsigen.github.io instead.
1
star