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, ie 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.
/** @type Node*/
A.prototype.x = undefined;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.