JSDoc conformity checks

Skip to first unread message

Georgiy Ivankin

Jan 23, 2013, 12:08:12 PM1/23/13
to closure-lin...@googlegroups.com
When I found Linter I thought that it will validate the JSDoc annotations and throw an error/warning if, e.g., I assign a string to a variable marked as number. The same thing that IDEs do, but from command line, so could be used in CI.

However, it turned out that Linter does not performs such checks, it only checks for JSDoc style validity, e.g. periods at the end of descriptions etc.

I wonder if the support of actual JSDoc conformity validation is planned for Linter or it is by design out of scope of the tool.

If it's not planned, is there any tool that can actually check it that you know about? 

Also, are non-trivial google JSDoc annotations (like e.g. {?number} or {function(string, ...[number]): number}) supported by any tool, either command-line or an editor or an IDE?

I know these are several questions and would be grateful to anyone for answering any of them :)

Nick Santos

Jan 23, 2013, 12:28:59 PM1/23/13
to closure-lin...@googlegroups.com
Are you looking for Closure Compiler?

Nathan Naze

Jan 23, 2013, 12:30:58 PM1/23/13
to closure-lin...@googlegroups.com
Yes. The linter does not do type checking -- it tries only to check style.

The Closure Compiler has very extensive type checking, among other things.  The linter does not try to reimplement the functionality.


Georgiy Ivankin

Jan 24, 2013, 4:32:37 AM1/24/13
to closure-lin...@googlegroups.com
That sound strange, because I tried to feed intentionally wrong-typed code to Compiler and in does not produce any warning. E.g., it compiles the following, both from command line and via web application:

 * @param {number} b
 * @return {string}
function requiresNum(b) {
  /** @type {string} */
  var a;
  b = '1';
  a = 1;
  return a;

среда, 23 января 2013 г., 21:30:58 UTC+4 пользователь Nathan Naze написал:

Nathan Naze

Jan 24, 2013, 11:59:31 AM1/24/13
to closure-lin...@googlegroups.com
I copied your code, verbatim, into http://closure-compiler.appspot.com/ on Advanced mode and saw four type warnings.  Seems it's working.

Reply all
Reply to author
0 new messages