Skip to content

Regression: Argument of type 'awaited T' is not assignable to parameter of type 'T' #37534

Closed
@Pajn

Description

@Pajn

TypeScript Version: 3.9.0-dev.20200322

Search Terms:
awaited

Code

async function runSequentially<T>(
  executors: Array<() => Promise<T>>,
): Promise<Array<T>> {
  const result: Array<T> = [];

  for (const executor of executors) {
    result.push(await executor());
  }

  return result;
}

Expected behavior:
The above code should compile. The types area reasonable and it did compile in previous versions without awaited.

Actual behavior:
Type error on await executor():

Argument of type 'awaited T' is not assignable to parameter of type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'awaited T'.ts(2345)

Playground Link: Playground Link

Related Issues: #37526

Metadata

Metadata

Assignees

No one assigned

    Labels

    DiscussionIssues which may not have code impact

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions