Skip to content

Parser incorrectly rejects exponentiation whose LHS is an unparenthesized await, as in await a ** 2 #40916

Closed
@bakkot

Description

@bakkot

TypeScript Version: 4.1.0-insiders.20201002 [nightly]

Search Terms: exponentiation exponential async await operator parser

Code

async function f() {
    await 1 ** 1;
}

Expected behavior:

No error.

Actual behavior:

Error: "An unary expression with the 'await' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. (17006)"

Playground Link: Here

Related Issues: Couldn't find any.

Incidentally, the grammar in the error message is also wrong (or at least unusual) - it's normally "a" unary expression, not "an", in my experience, since most people pronounce it "yoon-ary" rather than "oon-ary".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions