VS Code: Automatically convert your Promise chains into async/await
Last updated: 20th July 2020
Visual Studio Code can now convert your long chains of Promise.then()
's into async/await
!
In theory, this should also work with Sublime Text when using the TypeScript plugin.
Note: You do not need to write TypeScript code to use this feature, it works with vanilla JavaScript.
How to use this feature
- Focus on some code which uses
.then()
with Promise related code - Click the lightbulb icon which appears in the line gutter
- Select 'Convert to async function'
Extra resources
I made a tip on how VS Code can convert your require statements into ES Module Imports.
_You can also check out this Twitter thread which includes some extra information.