Skip to content

Offer quick fix for some uses of 'await' outside an async context #46986

Closed

Description

@rbuckton

Originally discussed in #38483.

We currently offer a quick fix to add an async modifier if we parse await in a non-async context when the await is unambiguously an AwaitExpression:

image

However, we do not offer that quick fix if we parse await in cases where it is ambiguous (such as in a call expression):

image

We should consider special-casing the error message for await when it is ambiguous so that we can offer compatible quick fixes.

Activity

  1. DanielRosenwasser commented on Dec 2, 2021

    @DanielRosenwasser
    Member

    I think the idea is that instead of Cannot find name 'await'. we would possibly issue a special-cased diagnostic like

    Cannot find name 'await'. Did you mean to write this in an async function?
    

    and provide a quick fix for that.

  2. a-tarasyuk commented on Dec 2, 2021

    @a-tarasyuk
    Contributor
  3. DanielRosenwasser commented on Dec 3, 2021

    @DanielRosenwasser
    Member
  4. a-tarasyuk commented on Dec 3, 2021

    @a-tarasyuk
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions