I can't get Closure Annotations to work in a Node.js project

I've been happily using the clousure annotations on the client side, but it doesn't work for me in my node project.

Here is some code:

/**
*
* @param a {!Object}
* @return {number}
*/
function dummy(a) {
    'use strict';
}

function d2() {
    'use strict';
    dummy("asd");
}


Clearly I should get warnings that dummy isn't returning anything, and that when I call dummy with a string I should get a parameter type mismatch error.

I have the following project settings;

Inspections | Javascript | general | closure compiler syntax : checked, and severity set to error.
Inspections | Javascript | general | type mismatch problem : checked and severity set to error.

What's wrong?
3 comments
Comment actions Permalink

Hi Bruce.
You should reverse order of name and type in @param tag, e.g.

/**
*
* @param {!Object} a
* @return {number}
*/

0
Comment actions Permalink

Ah - you are right, re the argument declaration. That fixes it.

But for the @return shouldn't I get a warning that I'm not returning anything? (Oh - I see it will warn if I return the wrong type, just not if don't return anything. Maybe I need to enable that?)

Also - is there an option so WebStorm will till me when my Closure annotation are wrong? It's so very easy to get something slightly wrong..

Thanks for your help!

0
Comment actions Permalink

You should enable inspection JavaScript | JavaScript validity issues | Functions with inconsistent returns, which is in Inspection-JS plugin.
Slight JSDoc consistency check is performed by JavaScript | General JSDoc comment matches function signature inspection. If you have other suggestions, please file them to the issue tracker:) And there is already an issue describing your situation, please watch it.

0

Please sign in to leave a comment.