node-typedjs is the node module, and more, for TypedJS

TypedJS is described as “lightweight program specifications for testing JavaScript”

In a nutshell you can annotate your functions with Haskell-like type signatures and then run a set of tests against those functions thus ensuring type safety. TypedJS will probably help you find some bugs in your code that you otherwise may not have found.

What it does

node-typedjs helps you test your JavaScript projects via the command line or programatically.

It gives you access to a few neat features like contracts via the enforce() method which enforce the types at runtime.

The contracts can be used along with your unit tests to assert that your functions are behaving as intended.

Similar to, typedjs aims at solving the problem differently.


addition.js contains your function along with its type signature.

//+ add :: Number Number -> Number
function add(a, b) {
  return a + b;

addition-test.js is your unit test as well as the typedjs checks.

var typedjs = require('typedjs');
var fs = require('fs');
var assert = require('assert');

typedjs.enforce(fs.readFileSync('addition.js').toString()); (context) {
  assert.equal(context.square(3), 9); // pass
  assert.equal(context.square('foo', 'bar'), 'foobar'); // fail

Even though both assertions would pass, the typedjs check will fail on the second call since a number is expected.

node-typedjs will let you:

Getting node-typedjs

You will need node.js

Install using npm


$ npm install typedjs


$ npm install typedjs -g

Standing on the shoulders of giants

node-typedjs would not be possible without open-source software such as