Introduction
You can’t use ReScript to call ReScript incorrectly because the compiler will help you make it correct. You can’t use ReScript to call JavaScript wrong because the compiler will help you make it correct.
However, when JavaScript calls your ReScript library, it can do it incorrectly because JavaScript has no compiler; you just run it. This can ruin all the benefits of ReScript: null pointers, runtime errors, and super strange internal ReScript standard library errors that make no sense with stack traces that are not helpful.
Instead, the better thing to do is check the types at runtime, and if wrong, provide helpful runtime errors with what the JavaScript developer needs to do to fix the error. If you’re a ReScript developer providing libraries for JavaScript developers, this article is for you.
(more…)