3

I would like to specify in Eclipse/JSDT the type of an instance variable as in the following example:

/**
 * @constructor
 */
function A() {
    /** @type Node */
    this.x = document.createElement("p");
}

The IDE, however, does not recognise the type of x. On the other hand, a declaration like

/** @type Node */
var x;

does work, i.e. in this case, x is known to have the type of a Node.

If I add

A.prototype.x = new Node();

to the first example, x will be known as a variable of type Node. However, this code does not run.

Marc
  • 4,327
  • 4
  • 30
  • 46

1 Answers1

0
/** @type Node*/
A.prototype.x = undefined;
inf3rno
  • 24,976
  • 11
  • 115
  • 197