I was getting some odd runtime type errors while switch from Js.Promise
to Js.Promise2
. So looking at the file js_promise2.res
, I see the following:
/** Type-safe t-first then */
let then: (promise<'a>, 'a => promise<'b>) => promise<'b> = %raw(`
function(p, cont) {
Promise.resolve(p).then(cont)
}
`)
/** Type-safe t-first catch */
let catch: (promise<'a>, error => promise<'a>) => promise<'a> = %raw(`
function(p, cont) {
Promise.resolve(p).catch(cont)
}
`)
Notice that those functions lack a return
, so they fail to actually return anything.