-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect lexing of TLA await in try...catch #38483
Comments
Hi, This seems to be a problem with all the top level statements of the form I'm gonna work on it. |
Today I was adding some code to a function and needed to make the function
And typescript gives me this strange error:
And I'm like WHAT THE??? WHAAAT?? WHY?? And I search for the error message and I find this issue, and I'm very very confused for a long time, thinking that typescript does not support syntax like I now realize that I have put the Update: And now, after writing this, I'm looking at this issue again, and I realize that typescript actually does not support such syntax in some cases. Seems like I only found a case that the support is there, but a bad error message made me think it was not. And I'm now thinking WHY would fixing this issue be postponed for such a long time... |
Outside of an async function or the top level of a module, |
I created #46986 to track the possibility of adding a distinct error message for an ambiguous |
TypeScript Version: 3.8.3
Search Terms: top level await, try catch
Code
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
The text was updated successfully, but these errors were encountered: