explaingit

rescript-lang/rescript

7,371ReScriptAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A typed programming language that compiles to clean, readable JavaScript, catching errors before your code runs so you get fewer runtime surprises, while staying compatible with existing JavaScript and TypeScript projects.

Mindmap

mindmap
  root((repo))
    What it does
      Typed language
      Compiles to JavaScript
    Key features
      Compile-time errors
      No any escape hatch
      Readable JS output
    Integration
      Use JS libraries
      Auto TypeScript defs
      Existing JS projects
    Tech stack
      ReScript compiler
      JavaScript
      TypeScript
    Tooling
      VS Code support
      Vim support
      Online playground
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add ReScript to an existing JavaScript project to get compile-time type checking without rewriting the whole codebase.

USE CASE 2

Publish a ReScript library that TypeScript users can consume directly through the automatically generated type definition files.

Tech stack

ReScriptJavaScriptTypeScript

Getting it running

Difficulty · moderate Time to first run · 30min
The compiler core is LGPL (modifications to it must be shared), while the standard library and other packages are MIT (use freely for any purpose including commercial).

In plain English

ReScript is a programming language that you write instead of JavaScript, and then a compiler turns your code into JavaScript that runs in a browser or on a server. The point is that ReScript catches errors at compile time, before your code ever runs, which means fewer surprises when users actually interact with your app. The output JavaScript is clean enough to read and debug directly, so you are not locked into the toolchain. The main appeal compared to writing plain JavaScript is the type system. Every value in a ReScript program has a type the compiler knows about, and it refuses to build if something does not add up. There is no equivalent to the JavaScript situation where a function quietly receives the wrong kind of data and produces confusing results at runtime. The README specifically notes there is no "any" escape hatch and no magic types. ReScript is designed to work alongside existing JavaScript projects rather than requiring you to rewrite everything. You can use JavaScript libraries from within ReScript, and you can publish ReScript code as a regular JavaScript library for people who do not use ReScript at all. It also generates TypeScript type definition files automatically, which makes integration with TypeScript codebases straightforward. The compiler is described as fast enough that large codebases do not suffer long rebuild times, and the project ships editor support for VS Code and Vim. There is an online playground where you can try ReScript in a browser without installing anything. The project is used by several companies in production and is maintained by the ReScript community. The license is a mix of LGPL (for the compiler core) and MIT (for the standard library and other packages).

Copy-paste prompts

Prompt 1
I want to add ReScript to my existing React JavaScript project. Walk me through installing the compiler, writing my first ReScript component, and making sure it interops with my existing JS files.
Prompt 2
How do I call an existing JavaScript library from ReScript? Show me the binding syntax and how to handle values that might be null or undefined.
Prompt 3
I'm getting a ReScript type error that says the types don't match. Explain what the error message means and show me how to fix a mismatched type in a function signature.
Open on GitHub → Explain another repo

← rescript-lang on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.