google / google/closure-compiler
IThenable's (and thus goog.Promise's) non-success result cannot be expressed in Closure compiler's types
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
IThenable. (from the common Thenable spec) is a promise for something of some type TYPE:
https://github.com/google/closure-compiler/blob/master/externs/es6.js#L704
But there's also the type that expresses an error, and the type that's passed to notify - ideally it'd be IThenable.. However that cannot be expressed in Closure's type system - the .then(fn(T): T2, fn(R): R2, fn(N): N2) method will return a new IThenable that should have new types inferred from the functions where the functions were passed in, i.e. not undefined (or null in practice).
AFAICT this cannot be expressed in Closure compiler, making promises harder to use, and migration to standard promises less promising (ha!).
Contributor guide
Assessment
This issue has not been assessed yet.