DEV Community

Cover image for Why GitHub Copilot and JSDoc Are a Dynamic Duo on VS Code
Federico Moretti
Federico Moretti

Posted on

Why GitHub Copilot and JSDoc Are a Dynamic Duo on VS Code

Just like any developer, I’m allergic to documentation: even though I try to write clean, maintainable code, and comment it wherever possible. So, talking about standards, I use JSDoc and I encourage my colleagues to do the same. Consistency is key, so I think that you should as well.


If you remember, I disabled inline suggestions for VS Code, since I don’t need them most of the time and find it difficult to dismiss them. This is not the case for code comments—I didn’t change my mind in two months. GitHub Copilot is an ideal companion to include automatic commenting.

Let’s say that you need to use it carefully, because its efficiency belongs to the time when you start receiving suggestions. I noticed it’s far better if you complete your function, for example, then you come back at the top of it and type a single-line or a multi-line comment character to get the hints.

If you miss some part of the function, such as an argument it must accept, the suggestions will be less precise and you’ll need to modify the suggested comment manually. I think that in any case it’s better to pay attention and read with care what Copilot writes down, but in general it works.

I also think that the lucky pairing comes from the availability of JSDoc sources on GitHub: I’m talking about a de facto standard, established in 2011, which hosts its knowledge base on the same provider that maintains Copilot. Maybe, the ideal environment for leveraging AI—with the help of models from Azure.

Sometimes I forget to remember that Microsoft owns both Azure and GitHub, so they can easily work together to provide the best experience. VS Code is the obvious choice in this perspective, but Copilot runs on Eclipse, JetBrains, Xcode, etc. as well. I’ve never tried it with one of them, though.

There were several unofficial JSDoc extensions for VS Code, but I do think that the built-in implementation is enough to get the best out of it. In fact, you can have a pretty decent automation even without Copilot, since the IDE provide a good completion for code commenting.

The added value of AI comes from the comments themselves. I mean, while VS Code gives you just a JSDoc-compatible generic template based on what you wrote, Copilot fills it with substantial contents. This, along with the well known IntelliSense support, does the trick.

I find GitHub Copilot code comments “verbose”, in the positive sense of the word, because they tend to repeat the same concept for each tag: this can be annoying if you’re a maintainer, but it’s very useful for newcomers… and you should think especially about them, when documenting your work.

JSDoc does its best with TypeScript, in my opinion, and Copilot seems to fit well. VS Code supports syntax highlighting for types, so you can clearly see them once set. Unfortunately, I can’t find a way to separate inline suggestions for documentation from those for code. It would be a great improvement.


I’ll come back on documentation, being a hot topic to date, and I also want to say something about GitHub Copilot and its available models: there’s more than the preview release of GPT-5—and I wish to build a Swagger UI open source alternative one day, since there are fewer then I expected.

Top comments (0)