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

sandersn picture sandersn  路  265Comments

metaweta picture metaweta  路  140Comments

kimamula picture kimamula  路  147Comments

rbuckton picture rbuckton  路  139Comments

chanon picture chanon  路  138Comments