Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webstorm JSDOC与显示模块模式_Webstorm_Jsdoc3 - Fatal编程技术网

Webstorm JSDOC与显示模块模式

Webstorm JSDOC与显示模块模式,webstorm,jsdoc3,Webstorm,Jsdoc3,我有返回对象的函数。我希望将它们的jsdoc定义放在webstorm intellisense上,以查看它们的属性和方法 如何编写以下函数的jsdoc function MyOtherFunc() { return { a:'for eg string', b:12 } } function MyFunc() { var prop = MyOtherFunc(); function myMethod() { alert( 'my method' ); } fun

我有返回对象的函数。我希望将它们的jsdoc定义放在webstorm intellisense上,以查看它们的属性和方法

如何编写以下函数的jsdoc

function MyOtherFunc() {
  return { a:'for eg string', b:12 }
}

function MyFunc() {
  var prop = MyOtherFunc();

  function myMethod() {
    alert( 'my method' );
  }

  function myOtherMethod() {
    alert( 'my other method' );
  }

  // explicitly return public methods when this object is instantiated
  return {
    someMethod : myMethod,
    someOtherMethod : myOtherMethod
  };      
}

在WebStorm中,如果不使用JSDoc,也可以正确处理此情况,但您可以使用:

/**
 * @return {{a: string, b: number}}
 */
function MyOtherFunc() {
    return { a:'for eg string', b:12 }
}

你应该能够完成你想用的,并且

如果
MyFunc
有任何静态方法,您只需关闭
@instance
或显式地将其标记为


在这种情况下,使用
@memberof
@static
应该是可选的。解析器应该能够自己解决这个问题;但是,无论如何,您可能希望显式地使用它们,以使阅读代码的任何人都能清楚地看到它。

我过去曾经这样做过,但最近很难记住以前是如何做的。在试图解决问题时遇到了您的问题。:-)
/**
 * @namespace MyFunc
 */
function MyFunc() {
  var prop = MyOtherFunc();

  /**
   * Does myMethody things
   *
   * @memberof MyFunc
   * @instance
   */
  function myMethod() {
    alert( 'my method' );
  }

  /**
   * Does myOtherMethody things
   *
   * @memberof MyFunc
   * @instance
   */
  function myOtherMethod() {
    alert( 'my other method' );
  }

  // explicitly return public methods when this object is instantiated
  return {
    someMethod : myMethod,
    someOtherMethod : myOtherMethod
  };      
}
/**
 * Say hello
 *
 * @param {string} [name] - Who to say hello to
 * @memberof MyFunc
 * @static
 */
MyFunc.helloWorld = function (name) {
  console.log('Hello ' + (name || 'world'));
}