'Unresolved function or method' when calling inherited method - How to document/define inheritance in JS?

Hello all,

I am experiencing an isssue with the code completion of methods inherited from a '"super class's" prototype in Node.js application I am writing. Currently, whenever I attempt to call a method* defined on the parent class, I get an error telling me 'Unresolved function or method foo()'. I am using the JSDoc style documentation syntax it is working as expected in most cases; however I suspect I am doing something wrong or perhaps I am acheiving inheritence in a way that Webstorm's parser does not understand. In any case, here's an example of what I am doing

* The code actually works as expected, but when the source code is defined the editor gives a visual warning

//Define Parent Class:
* Establishes the base class for controllers in this application
* @class BaseController
* @constructor
function BaseController(){
  this._privateStaticProperty = "Foo";

* A method to be inherited from subtypes of BaseController
* @param {Object=} optionalParam An optional parameter to this method
* @returns {*}
BaseController.prototype.inhertedBySubClass = function inheritedBySubclass(optionalParam){
// Do stuff

module.exports = BaseController;

An then in subclasses:

var BaseController = require("./path/to/BaseController");
var util = require('util'); // Core Node.js module

* An example subclass controller
* @class SubControllerA
* @param {!Object} dependency An external dependency of this class
* @constructor
* @extends {BaseController} BaseController
* @returns {SubControllerA} this returns a reference to the instance created by the Ctor
function SubControllerA(dependency){
if(dependency && toString.call(dependency) === '[object Object]'){
    this.inheritedBySubClass(dependency) // Here the parser adds the squiggly underline and message 'Unresolved function or method inheritedBySubClass()'
return this;
util.inherits(SubControllerA, BaseController); // Set the prototype chain of SubControllerA to referebce the prototype chain of BaseController

// Other method implemented below...

module.exports = SubControllerA;

1 comment
Comment actions Permalink

Hello Michael,

Thanks for the question. Actually, inheritance here recognized in three ways: @extend, BaseController.call(this) and util.inherits. So you are using it perfectly correct:) But we have a bug with CommonJS modules -  I've created an issue about it.


Please sign in to leave a comment.