I am very new in JSDoc, and I am trying out Webstorm, so I am also very new on webstorm.
I have on one hand an interface declared this way:
/** @interface */
function IInterface(){}
IInterface.prototype.myMethod = function(){};
On another hand, I am developing a module in which I am implementing this interface:
window.exports.MyImplementation = (function(){
"use strict";
/**
*
* @constructor
* @implements {IInterface}
*/
function MyImplementation(){}
MyImplementation.prototype.myMethod = function(){
// my implementation here
};
return MyImplementation;
})();
The problem I have is that the implementation is apparently not recognized:
But if I remove the window.exports.MyImplementation assignation or the return statment, there is no more warning...
.. but I do want to return and store my type from my module!
Is there something I am missing or doing wrong?...
Edit:
Just to bring a bit more confusion to my issue, I was considering using a "full annotation" interface declaration (If it is possible, I am experimenting here...):
... but in this case, you can notice that the "I" symbol has disappeared from the left side and if the method is not implemented, I don't have any warning. BUT the type IInterface is recognized.
Edit: I think I just understood something while experimenting other stuffs of jsDoc. The warning is thrown because the check on the implementation is made on the window.exports.MyImplementation. But there is no direct assignation implementing this object in the code. And this is why the warning is disabled when I remove the return statement or the "exports.MyImplementation" assignation.
.. thus, not sure this could be considered as a bug, this may be the pattern I used for my module that doesn't match to the pattern expected by WebStorm and maybe also by the JSdoc itself...... If someone who has experience in JSDoc and Webstorm could confirm.....
Another edit: (significant step here in understanding JSDoc I think)
The annotations have been moved on the targeted field and... tadaaa (notice the "I" which is still here indicating the interface is indeed implementing).
My explanation: There could be a logic behind that.... but honestly I really don't know if it is relevant: as the documented field will be exported in "exports.MyImplementation" at the very end, and this is evident the annotation is more useful here than in the private enclosure. WebStorm has detected the exportation to "exports.MyImplementation", thus is waiting for the documentation on it...
Does it make sense?...
And another edit (again) Investigation, investigation.
I have found a quite different solution that allows documentation, completion, validation and no warning, which seems to me a better solution for module exportation:
it's a bug in WebStorm JSDoc support, please vote for WEB-14202
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