1

我正在使用 Komodo IDE 开发一个 JavaScript 库,但我希望我的 IDE 知道我拥有哪些类型的对象以及它们的作用。特别是,我正在尝试解决这样的问题。考虑以下:

NS = {
    Template: {
        Class1: function() { 
            this.arg1 = 0;
        }
    }
}

/**
 * @return {NS/Template/Class1}
 */
function test()
{
    return new NS.Template.Class1();
}

var tmp = test();
tmp. // that should give me a select box with "arg1" present

但是上面的例子不起作用。我在想要么我在 @return 中错误地指定了命名空间,要么 IDE 根本不支持这个。以下示例不是我想做的事情,但它有效:

NS = {
    Template: {
        /**
         * @type __Class1
         */
        Class1: __Class1 // this is only here for access via NS.*
    }
}

function __Class1()
{
    this.arg1 = 0;
}

/**
 * @return {__Class1}
 */
function test()
{
    return new __Class1();
}

var tmp = test();
tmp. // that does give a select box with "arg1" in it

基本上我要问的是,是否有人知道如何使用评论使 IDE(如果可能的话,Komodo)识别“命名空间”中的类。第二个例子虽然有效,但对我来说似乎很丑陋,我不想使用它。

谢谢你的想法

4

0 回答 0