Closed
Description
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