question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
RyanCavanaughcommented, Jan 6, 2021

😞✋ Fixing tricky parser bugs 😀👉 Having the spec change to match your behavior

2reactions
JLHwungcommented, Jan 6, 2021

@a-tarasyuk @jonhue Note that in TC39 November 2020 meeting we have reached consensus that await x ** 1 is illegal, so current engines (except TS!) are not conforming to the spec.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to reject in async/await syntax? - Stack Overflow
You can create a wrapper function that takes in a promise and returns an array with data if no error and the error...
Read more >
await - JavaScript - MDN Web Docs
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async...
Read more >
Handling those unhandled promise rejections with JS async ...
One of your await ed functions fails (i.e. rejects a promise); You get the error. Another possibility is that you know you need...
Read more >
5. Async functions - Exploring JS
If the Promise is rejected, await throws the rejection value. Handling a single asynchronous result: async function asyncFunc () { const result =...
Read more >
JavaScript Promise Tutorial – How to Resolve or Reject ...
There are a few ways to come out of (or not get into) callback hell . The most common one is by using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found