Javascript - (Static) Typing (Checker)


Data Type - Static Typing in JavaScript.


Typing can be added with this method:

Documentation Annotation


JSDoc annotation

in js file: with Typescript checkJs (to true) and Jsdoc Ref

See typescript supports it via Jsdoc

  "compilerOptions": {
    "noEmit": true,
    "allowJs": true,
    "checkJs": true,
    "target": "es2017",
    "module": "commonjs"
  "include": [


the Google Closure types syntax (works within Idea).

  • Simple Type: Type of parameter or variable is specified on the left side
/** @param {number} x **/
function inc(x) {return x + 1;}
  • Constructor Type: Every constructor function “becomes” a type and its name can be referenced inside JSDoc tags.
function Point(x,y) { this.x = x; this.y = y; }

/** @param {Array.<Point>} points 
* Array of elements of some type could also be specified with [] (for example, Point[]).
function printPoints(points) {
  • It works also for the DOM
// @param {Node} domNode
// @param {HTMLElement} htmlElement
  • Return Type
/** @return {!Shape|undefined} */
  • Type annotation
/** @type {function(string, *)} */

Powered by ComboStrap