开发者

Eclipse JSDT - declaring the type of a function argument

开发者 https://www.devze.com 2023-03-19 10:06 出处:网络
Using Eclipse Helios: If I define a simple Javascript function /** * @returns {Number} * @param {String} arg

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?


Actually the JsDoc annotations in JSDT/Eclipse are meant for primarily two reasons(as per my comprehension, do correct me if its not the same)

  1. For generation of documentation and

  2. To let eclipse-JSDT-engine help the developer with auto suggest(case-specific).

    so the eclipse-developers are not just cross-checking the annotation bindings with your actual code implementation until you run the js file. And again, while you run the javascript. at run time the the javadoc annotations are overlooked as mere comments.

0

精彩评论

暂无评论...
验证码 换一张
取 消