0

A common bug in JavaScript is to forget the await keyword when calling an async function.

Of course you don't always want to await, sometimes you really want to get a promise. And of course you can't statically determine all target functions.

But there's still a vast majority of trivial cases that we'd like to check in order to avoid silly bugs.

Excluding naming schemes (which are cumbersome) what convenient strategies are there to deal with that problem ? Any linter ? checker ? colorization plugin ?

1 Answer 1

2

Use TypeScript.

  • TypeScript can statically infer and check JavaScript code. You don't need to have an actual build and/or compilation.
  • TypeScript has a fairly mature API for editors, or a node API if you want to run it yourself.
  • Visual Studio Code allows you to add a //@ts-check comment at the top of a file to instantly get errors displayed in the editor for the file.
1
  • Thanks. I just tested this idea. This is interesting. But I'm afraid it needs to work to have a little too much the JS code modified (or switch is to TypeScript which is a sane option but not the context of the question) Commented Jan 31, 2018 at 9:26

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.