Typescript: Incorrect lexing of TLA await in try...catch

Created on 11 May 2020  路  1Comment  路  Source: microsoft/TypeScript

TypeScript Version: 3.8.3

Search Terms: top level await, try catch

Code

try {
  await (async () => {})(); // TS2304 cannot find name 'await'
} catch {
  //
}

Expected behavior:

The file is considered valid.

Actual behavior:

The file has an error at await of "TS2304 cannot find name 'await'".

Playground Link: https://www.typescriptlang.org/play?#code/C4JwngBA3gUAkAQwO4IJbAgCgQZzAOwGMsBKCAXgD5oBfEzEgbhhokIWEIAtp4B6PixhA

Bug Rescheduled

Most helpful comment

Hi,

This seems to be a problem with all the top level statements of the form await (async () => { ... })() and not only in try...catch.

I'm gonna work on it.

>All comments

Hi,

This seems to be a problem with all the top level statements of the form await (async () => { ... })() and not only in try...catch.

I'm gonna work on it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Roam-Cooper picture Roam-Cooper  路  3Comments

blendsdk picture blendsdk  路  3Comments

CyrusNajmabadi picture CyrusNajmabadi  路  3Comments

Antony-Jones picture Antony-Jones  路  3Comments

DanielRosenwasser picture DanielRosenwasser  路  3Comments