Type-safe APIs for compile-to-JavaScript modules