I need a common place where I can import the typedef from, in order to not define the type Position in other used modules over and over again?
Is it possible to have a common file like common-type-defs.js,
where I can define `typedef``s for objects which actually don't have a type implementation in form of a class?
For example I have a typedef Position which I want to reuse in different modules:
/** @typedef {Object} Position
* @property {number} column
* @property {number} line
*/
/** @typedef {Object} Loc
* @property {Position} start
* @property {Position} end
*/
common-type-defs.js
/** @typedef {Object} Position
* @property {number} column
* @property {number} line
*/
/** @typedef {Object} Loc
* @property {Position} start
* @property {Position} end
*/
I need a common place where I can import the typedef from, in order to not define the type Position again?
Or do I have to create a common-types.js file with an implementation of Position and then imort it, like:
/** @typedef {import("./common-types.js").Position} Position*/
or reference typedef
file1.js
@reference typedef Position from `common-type-defs.js` // dummy code
Class XYZ{
@type {Position} position
constructor(position){
...
}
}
Your environment
| Software |
Version |
| JSDoc |
? |
| Node.js |
8.11.3 |
| npm |
5.8.0 |
| Operating system |
Win 10 |
I need a common place where I can import the typedef from, in order to not define the type
Positionin other used modules over and over again?Is it possible to have a common file like
common-type-defs.js,where I can define `typedef``s for objects which actually don't have a type implementation in form of a class?
For example I have a typedef
Positionwhich I want to reuse in different modules:common-type-defs.js
I need a common place where I can import the typedef from, in order to not define the type
Positionagain?Or do I have to create a
common-types.jsfile with an implementation ofPositionand then imort it, like:/** @typedef {import("./common-types.js").Position} Position*/
or reference typedef
file1.js
Your environment