Skip to content

Typing issue: async function not accepted as forEach callback #19

@vitaly-kiselev-qa

Description

@vitaly-kiselev-qa

In the current TypeScript type definitions, the forEach function is declared as:

export const forEach: <T>(
  array: T[],
  callback: (currentValue: T, index: number, array: T[]) => void,
  thisArg?: any
) => Promise<void>;

See index.d.ts.

This signature implies that the callback must return void.
However, the documentation states that it should be asynchronious:

Allow the usage of async functions as callback

See README.md.

I guess, the function should return void | Promise<void>.

The current definition produces the linter error:

Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises

See no-misused-promises.

Could you please consider updating the typing?

Thank you!

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