-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Regression with await type extraction in strict mode #32752
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 3.6.0-dev.20190807 (worked up to 3.6.0-dev.20190804)
Search Terms: await type promise
Code
const containsPromises: unique symbol = Symbol();
type DeepPromised<T> =
{ [containsPromises]?: true } &
{
[TKey in keyof T]: T[TKey] | DeepPromised<T[TKey]> | Promise<DeepPromised<T[TKey]>>
};
async function fun<T>(deepPromised: DeepPromised<T>) {
const deepPromisedWithIndexer:
DeepPromised<{ [name: string]: {} | null | undefined }> = deepPromised;
for (const value of Object.values(deepPromisedWithIndexer)) {
const awaitedValue = await value;
if (awaitedValue)
await fun(awaitedValue);
}
}(Compile with --strict!)
Expected behavior:
No compile error as in TS 3.5.3.
Actual behavior:
TypeScriptIssueNext.ts:21:23 - error TS2345: Argument of type '{} | ({ [containsPromises]?: true | undefined; } & {})' is not assignable to parameter of type 'DeepPromised<{ [containsPromises]?: undefined; }>'.
Types of property '[containsPromises]' are incompatible.
Type 'true | undefined' is not assignable to type '(true & Promise<never>) | undefined'.
Type 'true' is not assignable to type '(true & Promise<never>) | undefined'.
21 await fun(awaitedValue);
~~~~~~~~~~~~
Playground Link: Here
BTW: Please update the libs in the playground, Object.values() (ES2017) isn't available.
Related Issues: -
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue