javascript - How to document @typedef as @memberof a @namespace - Stack Overflow

I should point out that I am using VSCode as my IDEQuestionHow do I document a @typedef such that it is

I should point out that I am using VSCode as my IDE

Question

How do I document a @typedef such that it is a member of a @namespace? (I am open to @module or other JSDoc tags to achieve this, but seemed to be getting closest with this approach)

I am working on a React project and have my domain objects represented as entities

folder structure

- entities/
  - group/
    - group-actions.js
    - group-model.js
    - group-reducer.js
    - group-selectors.js
    - group-service.js
    - index.js

index.js

import Actions from './group-actions';
import Model from './group-model';
import reducer from './group-reducer';
import Selectors from './group-selectors';
import Service from './group-service';

/**
 * GroupNamespace
 * @namespace Group
 */
const Group = {
  Actions,
  Model,
  reducer,
  Selectors,
  Service,
};

/**
 * Group
 * @typedef {Object} GroupInstance
 * @memberof Group
 * @property {Object[]} members
 * @property {Object} permissions
 */

export default Group;

Now, I would like to define a React ponent that receives a GroupInstance as a prop

I would expect to see members in that intellisense dropdown, but do not.

Now, if I change the @property definition to @property {Group} group I do get intellisense on the @namespace

I should point out that I am using VSCode as my IDE

Question

How do I document a @typedef such that it is a member of a @namespace? (I am open to @module or other JSDoc tags to achieve this, but seemed to be getting closest with this approach)

I am working on a React project and have my domain objects represented as entities

folder structure

- entities/
  - group/
    - group-actions.js
    - group-model.js
    - group-reducer.js
    - group-selectors.js
    - group-service.js
    - index.js

index.js

import Actions from './group-actions';
import Model from './group-model';
import reducer from './group-reducer';
import Selectors from './group-selectors';
import Service from './group-service';

/**
 * GroupNamespace
 * @namespace Group
 */
const Group = {
  Actions,
  Model,
  reducer,
  Selectors,
  Service,
};

/**
 * Group
 * @typedef {Object} GroupInstance
 * @memberof Group
 * @property {Object[]} members
 * @property {Object} permissions
 */

export default Group;

Now, I would like to define a React ponent that receives a GroupInstance as a prop

I would expect to see members in that intellisense dropdown, but do not.

Now, if I change the @property definition to @property {Group} group I do get intellisense on the @namespace

Share Improve this question edited Apr 5, 2018 at 2:02 ken4z asked Apr 1, 2018 at 16:20 ken4zken4z 1,3901 gold badge11 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Documentation for @typedef is found at https://jsdoc.app/tags-typedef.html#syntax.

I've found you have two options:

Option 1 is to use @typedef and append with data type, and include separate @name and @memberOf Option 1 Example:

/**
* Your description goes here.
* @typedef {type}
* @memberOf module:your/module
* @name yourTypedefName
*/

Option 2 is to omit @name and @memberOf, and define full path with data type in @typedef - https://jsdoc.app/tags-typedef.html Option 2 example

/**
 * Your description goes here.
 * @typedef {Object} module:your/module.yourTypedefName
 */

Also, you can put @type as separate line as well with the type, then for Option 1, your line with @typedef will just have @typedef on it.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744889436a4599313.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信