Skip to content

Error for missing await in conditional #25330

Closed
@mjbvz

Description

@mjbvz

TypeScript Version: 3.0.0-dev.20180626

Search Terms:

  • await
  • conditional
  • diagnostics

Code

async function foo(): Promise<boolean> {
    return false;
}

async function bar(): Promise<string> {
    if (foo()) {
        return 'true';
    }
    return 'false';
}

Expected behavior:
A warning or error or suggestion is generated in the if conditional since it will always be true. The user almost certainly intended to await the result of foo instead.

Possibly also have a quick fix to add the await

Actual behavior:
No errors or warnings. Code does unexpected things

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions