I am applying JSDoc annotations:
/**
* @param {number} millis
* @param {function} callback
* */
function sleep(millis, callback) {
setTimeout(function() {
callback();
}, millis);
}
Then what tool would tell there is an error for line below?
sleep('aaa', 'sdsdsd');
Is JSHint aware of JSDoc type annotations? How to enable such support in Eclipse?
jshint is not aware of jsdoc comments. You could however look at using eslint and writing a plugin for it that would perform type checking on function calls. Depending on how your project is set up you might end up having to pre-parse your code to extract the comments into a rules file that your eslint rule would use.
Disclaimer, I'm the author of tern.java.
I suggest you that you install tern.java 1.0.0-SNAPSHOT. It provides the capability to validate your JavaScript files by using JSDoc annotations. Here a screenshot with the sample of this issue :
If you need improvement with JSDoc validation, please create issues here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With