-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Top-level await
error message is extremely unclear
#36036
Comments
Yeah, this is a tough one to write concisely. Do you have a better suggestion? |
When it occurs at the top level of a file (not a regular function), regardless of compiler options:
and when the options are wrong:
When in a regular function
|
Would you report both of the top two errors if both are a problem? |
Should we have a codefix for the first one to add an Also, have we considered adding codefixes to fix the |
Personally, I'd prefer just one at a time, but both are fine at once.
Always!
I think we do, but check with @sheetalkamat |
I'm generally not a fan of fixing one error just to end up with another error when the fix had nothing to do with the second error. I'd rather get both so I know all the actions I need to take. |
No we haven't done that yet and there is #30739 that needs something similar... |
Actually, it looks like we have. We have fixes already for enabling |
@DanielRosenwasser: Having a codefix to change your |
|
What do you think of these code fix names? For
For
I like being able to do both in one action, but
|
Consider the following: // file.ts
await 1;
export {};
// tsconfig.json
{ "compilerOptions": { "target": "es5" } } We would be able to fix the |
I think it's fine to say "no, we can't give a quick fix in all cases", and that might be one of them |
After struggling with error Please adjust the error message to provide a hint, that apart from adjusting the |
It fixed for me when I changed |
Yeah @serg06 is right here. Why do |
Why do we still need to add |
If that's not the behavior you want, in newer versions of TypeScript, you can configure this with the |
Also think having a More and more ppl are starting to use ESM, so your assumption that ppl use cjs or script by default is, Meh. |
This gives the following error message:
This is really unclear! My compiler options are all set correctly, so why is this not working?
It's because it's not a module. This error message is expecting me to meet 3 different conditions, "top level of a module" is unclear for any user who just wants to use this feature. They'll likely take "module" to just mean "file".
The text was updated successfully, but these errors were encountered: