That’s definitely an interesting idea. Maybe by an annotation or similar:
@toResult
external somethingThatCouldThrow: string => string = "somethingThatCouldThrow"
// let somethingThatCouldThrow: string => result<string, JsExn.t>
@xfcw if you’re interested in this, would you open an issue on the compiler issue tracker so we have somewhere to discuss? It’s off topic for this thread of course.