«   Previous tip Next tip   »

VS Code: Automatically convert your Promise chains into async/await

Last updated: 20th July 2020
Automatically convert your Promise chains into async/await

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

  1. Focus on some code which uses .then() with Promise related code
  2. Click the lightbulb icon which appears in the line gutter
  3. 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.

«   Previous tip Next tip   »

Sign up to receive a developer tip, in the form of a gif, in your inbox each week