aantron / promise

Light and type-safe binding to JS promises
MIT License
340 stars 24 forks source link

Provide type abbreviation for promises that reject with Js.Promise.error #71

Open aantron opened 3 years ago

aantron commented 3 years ago

From Discord:

nitpicking, you could save a line by binding login directly as a reason-promise:

external login: unit => Promise.Js.t(authResponse, Js.Promise.error) = "login"

then you can get rid of the ->Promise.Js.fromBsPromise, which is a no-op at run time anyway.

looking at that, it might be good to add a helper type abbreviaton to the library, so you can do something like

extern login: unit => Promise.Js.raw(authResponse) = "login"