Repository navigation
Auto-insert await for property accesses on Promise #31450
Description
Activity
This seems like a good idea but should only be done inside
asyncfunctions if possible. In the example above, the function is not async so adding anawaitthere would make the code invalid.Reacted by Daniel Rosenwasser, Titian Cernicova-Dragomir and Pierre PACIReacted by Daniel RosenwasserDanielRosenwasser commented
on May 18, 2019 MemberAuthorMore actionsYes, thank you, that was one of the subtler points I forgot to add to this issue. It would be incredibly annoying/unsafe otherwise.
- addedDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorSuggestionAn idea for TypeScriptAn idea for TypeScript
on May 18, 2019 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.
Reacted by Daniel RosenwasserDanielRosenwasser commented
on May 22, 2019 MemberAuthorMore actionsSpoke with Daniel Ehrenberg (@littledan) today, and once top-level
awaitlands, we should consider doing this at the top level based ontargetandmoduleoptions.Reacted by Daniel Ehrenberg, Bo Lingen and SlurpTheo- addedEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this
on May 25, 2019 andrewbranch commented
on Jun 26, 2019 MemberMore actionsRelated: #30646
andrewbranch commented
on Jun 26, 2019 MemberMore actions/cc Brian Terlson (@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:
- The target of a member expression and T has the member (or maybe the property name is not in Promise).
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.
1 remaining item
Another quick fix is better, the current completion behavior seems cannot add
asyncmodifier simply as far as I know- addedFix AvailableA PR has been opened for this issueA PR has been opened for this issueand removedHelp WantedYou can do thisYou can do this
on Jul 23, 2019 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
stringshould show up. When the user selects astringmember, we should automaticallyawaitthe value, so selectingtoLowerCasechanges the code to(await x).toLowerCase.