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, *)} */

Discover More
Javascript (Js|ECMAScript)

Javascript was born to run in the browser but may know with the advent of node run on the server side. See JavaScript is also known as: Mocha, LiveScript, JScript (Windows Implementation),...
Javascript - Type

Type in Javascript Javascript is not static typed but it exist Javascript wrapper language that implements it. See Only values have types in JavaScript; variables are just simple containers for those...
Javascript - JsDoc

JavaScript Documentation Tool (JSDoc) is a tool that parses inline documentation in JavaScript source files, and produces an documentation of the JavaScript code. JSDoc is based on javadoc tool that...
React - prop-types (Type checking)

in React PropTypes exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're using PropTypes.string. When an invalid value is provided for a prop,...

Share this page:
Follow us:
Task Runner