Skip to content

Array.fromAsync type define on its mapFn missing the index as second argument #59836

@imcotton

Description

@imcotton

🔎 Search Terms

fromAsync index

🕗 Version & Regression Information

  • This changed between versions 5.4 and 5.5
  • This changed in commit or PR add Array.fromAsync to esnext #57748
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Array.fromAsync
  • I was unable to test this on prior versions because it only introduced in 5.4

⏯ Playground Link

https://www.typescriptlang.org/play/?target=99&jsx=0&module=0&ts=5.5.4#code/IIJxEME8DoDMQPYFtgGdIDsDGAKA2gAQDk4RANMQEZEEC6FOqALiBQJYYAmApgB4CUBALwA+AjgDeBDj14VmIAgF9+-ANxA

💻 Code

Array.fromAsync([ 'a', 'b' ], (str, index) => ({ index, str }));

🙁 Actual behavior

  • Argument of type '(str: any, index: any) => { index: any; str: any; }' is not assignable to parameter of type '(value: string) => { index: any; str: any; }'.
    Target signature provides too few arguments. Expected 2 or more, but got 1.
  • Parameter 'str' implicitly has an 'any' type.
  • Parameter 'index' implicitly has an 'any' type.

🙂 Expected behavior

index typed as number

Additional information about the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions