Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when a typedef is inside a module, return types stop linking to the type definition #969

Closed
lukeapage opened this issue Mar 27, 2015 · 4 comments

Comments

@lukeapage
Copy link
Contributor

In the following example, when jsdoc is generated (with the default template and docstrap) there is no link from the return type to MyType.

If I remove the module definition at the start it fixes it.

/** @module my/module */

/** @typedef {Object} MyType
    @property {string} prop
*/

/** 
  * My class
  * @class
  */
function Func() {
}

/**
   @returns {MyType} the return type
  */
Func.prototype.myfunc = function() {
};

I've tried prefixing MyType with the module and it doesn't help.

@hegemonic
Copy link
Contributor

This is not exactly obvious, but a typedef inside a module has inner scope by default. So this will work to link to MyType:

/**
 * @returns {module:my/module~MyType} the return type
 */
Func.prototype.myfunc = function() {};

If you prefer, you can add a @static tag to the typedef, and you can then link to it as module:my/module.MyType.

@manugb
Copy link

manugb commented Nov 26, 2015

Hey guys it would be nice to have if you parse the @returns or @param {module:my/moduleMyType}
so when you show the link it only says MyType and not module:my/module
MyType

@jtq
Copy link

jtq commented May 10, 2016

Alternatively you can just mark the inner typedef as @global and just refer to it as {MyType} anywhere you like, if you don't mind littering your global namespace with module-specific types.

This is irritating though - if inner typedefs are listed in the JSDoc documentation page for a module, what reasonable rationale is there for not linking to that typedef definition when it's used in JSDoc comments in that same module?

@rugk
Copy link

rugk commented Jan 20, 2019

BTW all people affected by this, probably upvote #1533.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants