Microsoft/TypeScript

Parser does not reject `await a as any ** 1`

Open

#41 755 ouverte le 1 déc. 2020

Voir sur GitHub
 (8 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
BugDomain: API: TransformsEffort: ModerateHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

TypeScript Version: 4.2.0-dev.20201201

Search Terms: exponentiation, await

Code

await a as any ** 1

Expected behavior: Parser should throw

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.

Actual behavior: Does not throw

Playground Link: https://www.typescriptlang.org/play?ts=4.2.0-dev.20201201#code/G4QwTgBCELwQCmA9gWwJYGcCmA6MWMkAbYLACgEYBKAbgCgQMBPAOwGMIyrYA+KAdxBoALlCgYoLJhABUMiBSA

Related Issues: https://github.com/microsoft/TypeScript/issues/40916, since in November meeting we have reached consensus that await x ** 1 is illegal and the parser already throws on await a! ** 1, I think it should either throw for await a as any ** 1, or add parenthesis in the output for await a if as any serves as an implicit parenthesis.

Guide contributeur