Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Regression with await type extraction in strict mode #32752

Copy link
Copy link
@ulrichb

Description

@ulrichb
Issue body actions

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.