[英]Type declaration/inference in Eclipse/JSDT
I would like to specify in Eclipse/JSDT the type of an instance variable as in the following example: 我想在Eclipse / JSDT中指定实例变量的类型,如下例所示:
/**
* @constructor
*/
function A() {
/** @type Node */
this.x = document.createElement("p");
}
The IDE, however, does not recognise the type of x
. 但是,IDE无法识别
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
. 确实有效,即在这种情况下,已知
x
具有Node
的类型。
If I add 如果我加
A.prototype.x = new Node();
to the first example, x
will be known as a variable of type Node
. 对于第一个例子,
x
将被称为Node
类型的变量。 However, this code does not run. 但是,此代码不会运行。
/** @type Node*/
A.prototype.x = undefined;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.