Skip to content

parse returns a promise although the type does not indicate so #155

Description

@altinokdarici

In parse.ts file, the blow code snippet returns a promise.

 if (!wasm)
    // actually returns a promise if init hasn't resolved (not type safe).
    // casting to avoid a breaking type change.
    return init.then(() => parse(source)) as unknown as ReturnType<typeof parse>;

This type hack causes issues on the consumption side. We call the parse function without awaiting as it's indicated by type system. However, we figured that parse may return Promise in the run time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions