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
1 Answer
Reset to default 6Documentation 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条)