-
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
Auto-insert await
for property accesses on Promise
#31450
Comments
This seems like a good idea but should only be done inside |
Yes, thank you, that was one of the subtler points I forgot to add to this issue. It would be incredibly annoying/unsafe otherwise. |
Something else I just thought of: since this would be done via autocompletion, the feature probably shouldn't get any ideas about automatically converting the function to async - doing so is a breaking change in most cases since it forces the function into returning a promise. |
Spoke with @littledan today, and once top-level |
Related: #30646 |
/cc @bterlson: Thoughts on this (and the work done already at #32101) as a partial solution for #30646? Personally, I’d still like to surface a quick fix and make sure we have a really good diagnostic message in addition to this, but I think completions are a good first line of defense for the last bullet point you mentioned:
|
I like it a lot, personally. Incrementally addressing the various bullets is fine by me, and I think this is probably one of the biggest rocks. |
The reason I put this proposal together was because when I spoke to @jonathandturner, I realized that better error messages (as in #30646) would only help TypeScript users, but would not help JavaScript users who aren't using type-checking. |
Another quick fix is better, the current completion behavior seems cannot add |
a suggestion: add a new keyword to a function and translate to js with await all variables. |
Go to the
/**/
marker and request completions.The proposal here is that all the completions for
string
should show up. When the user selects astring
member, we should automaticallyawait
the value, so selectingtoLowerCase
changes the code to(await x).toLowerCase
.The text was updated successfully, but these errors were encountered: