Skip to content

IThenable's (and thus goog.Promise's) non-success result cannot be expressed in Closure compiler's types #669

@mprobst

Description

@mprobst

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.<TYPE, REJECT, NOTIFY>. 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!).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions