Open
Description
Motivation
js_sys::Promise
-> js_sys::Promise<T = JsValue>
Better type system has obvious benefits.
Proposed Solution
- Add a generic to the
js_sys::Promise<T = JsValue>
- Adjust the calls like
then
to take aPromise<T>
and callback fromT
and return a differently-typedPromise<U>
. - Adjust TypeScript codegen to allow specifying the
T
type (currently it isPromise<any>
).
Alternatives
js_sys::Promise
-> js_sys::Promise<T = JsValue, E = JsValue>
- where E
is the typed rejection; this is not how TypeScript types them though, and there are issues in general with errors typing due to the JavaScript language model itself.
Additional Context
I want to replace impl Future<Output = T>
with js_sys::Promise<T>
in my bindings where applicable.