Closed
Description
Looks like resolving this problem by type inference is difficult. We may need unawaited operator.
TypeScript Version: 3.9.0-dev.20200322
Search Terms:
Expected behavior:
pass
Actual behavior:
Argument of type 'T' is not assignable to parameter of type 'awaited T | PromiseLike<awaited T> | undefined'.
Type 'T' is not assignable to type 'PromiseLike<awaited T>'.(2345)
Related Issues:
Code
function f<T>(a: T): Promise<awaited T> {
return new Promise(r => r(a));
}
Output
"use strict";
function f(a) {
return new Promise(r => r(a));
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": 2,
"target": "ES2017",
"jsx": "React",
"module": "ESNext"
}
}
Playground Link: Provided