I was reading http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml when I noticed in the Constant section with the annotated comments:
/**
* The number of seconds in each of the given units.
* @type {Object.<number>}
* @const
*/
and then the guide goes on with “This allows the compiler to enforce constant-ness.”
Is this a v8 thing? where is this documented?
My mind is giddy with the possibility that maybe, just maybe, i can provide v8 (or whatever) with type information!
The Google’s Closure Compiler can accept JSDoc comments, and it will generate warnings or errors.
For example, if you try to compile the following code with the Advanced Optimization:
It will generate an error:
They discourage the
constkeyword because it is not part of the ECMAScript Standard.