gitmyhub

rescript

ReScript ★ 7.4k updated 14h ago

ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript.

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.

ReScriptJavaScriptTypeScriptsetup: moderatecomplexity 3/5

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).

Where it fits