Reputation: 2339
What is the best method to use to extend a javascript "class" (note the air-quotes), so that Intell-J IDEA is aware that this object has a parent, and gives better completion support for the parents methods?
Upvotes: 2
Views: 293
Reputation: 92324
Intellij understands some styles of inheritance (Ext-JS, Prototype...), so you don't need to do anything if it supports your libray. The foolproof (haha) way is to add JSDoc
/**
* @class MyBase
*/
function MyBase() {}
MyBase.prototype.do = function() {};
/**
* @class MySub
* @extends MyBase
*/
function MySub() {}
MySub.prototype.doMore = function() {};
However, I've filed lots of bugs with them, and this is often buggy and seem to work and break with different versions. If it doesn't work in some cases for you, you should file a bug.
This screenshot shows you that Intellij does understand that MySub inherits from MyBase (see the (o) on the left? It's saying that the do method is overridden)
Upvotes: 1