1

Using Eclipse Helios:

If I define a simple Javascript function

/**
 * @returns {Number}
 * @param {String} arg 
 */
function test(arg) 
{
     return 1;
}
  • the tags were those automatically added by Alt-Shift0J - then the inferred type for the function is:
Number test(any arg)

Parameters:
{String} arg
@returns
{Number}

Note the "any arg", despite also Eclipse also recognising the parameter is "{String} arg" later.

Nothing I've tried get the inferred type of the arg to be anything other than "any". This means calling the function with a non-String isn't detected, which is a pity.

So, is this a bug? Not supposed to work? Something I'm doing wrong?

4

1 回答 1

0

实际上,JSDT/Eclipse 中的 JsDoc 注释主要有两个原因(根据我的理解,如果不一样,请纠正我)

  1. 用于生成文档和

  2. 让 eclipse-JSDT-engine 帮助开发人员自动建议(特定于案例)。

    因此,在您运行 js 文件之前,eclipse-developers 不仅仅是交叉检查注释绑定与您的实际代码实现。再一次,当你运行 javascript 时。在运行时,javadoc 注释被忽略为仅仅是注释。

于 2014-12-27T12:51:28.293 回答