Skip to content

Wrapped exports should return Promises #11

Closed
@fgmccabe

Description

@fgmccabe

The current spec of JSPI returns a Promise if the underlying wasm suspended (due to a call to a suspending import) and returns a regular value if the export 'returned normally'.
This is not a recommended approach to designing API for the web: return types of the form JSPromise | AnythingNotAPromise are not recommended.
The fix is to always return a Promise, and to have the final return value be the equivalent of
Promise.resolve(innerExport())

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