| Vadim Nicolai

Type checking with JSDoc

October 27th, 2019

Being able to catch bugs at compile time is a nice way to shorten feedback loop, thus become more productive. TypeScript provides static type checking. One way of integrating it in an app is refactoring entire app and adding type definition where those are needed. In some bigger apps this might take a noticeable effort.

Since TypeScript 2.3, an alternative solution has been developed by adding TypeScript and VS Code type checking support of JS files using JSDoc. This feature is optional and does not add any delays since nothing is transpiled.

This can be added in 2 ways:

  1. by inserting this comment at the top of .js file
// @ts-check


  1. by adding the following setting to VS Code settings.json file - "javascript.implicitProjectConfig.checkJs": true

Check this feature in action:

Type checking in JSDoc

Here is the official documentation for JSdoc support in TypeScript.

More Articles

Code Sharing Between React Web And React Native

One of the advantages of using React Native is the possibility of sharing code across different devices. This is achievable because under…
November 21st, 2018
© 2022 | Vadim Nicolai