【问题标题】:Type declaration/inference in Eclipse/JSDTEclipse/JSDT 中的类型声明/推断
【发布时间】:2012-03-13 18:56:31
【问题描述】:

我想在 Eclipse/JSDT 中指定实例变量的类型,如下例所示:

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

但是,IDE 无法识别 x 的类型。另一方面,像

这样的声明
/** @type Node */
var x;

确实有效,即在这种情况下,x 已知具有 Node 的类型。

如果我添加

A.prototype.x = new Node();

对于第一个示例,x 将被称为Node 类型的变量。但是,这段代码没有运行。

【问题讨论】:

    标签: javascript eclipse jsdoc jsdt


    【解决方案1】:
    /** @type Node*/
    A.prototype.x = undefined;
    

    【讨论】:

      猜你喜欢
      • 2011-10-02
      • 1970-01-01
      • 1970-01-01
      • 2019-06-29
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多