如何在mixins上的extends / inherit情况下正确地为Node.js模块定义JSDoc

我有三个Node.js模块。 一个被调用的userbase模块获得inheritance。 handler模块与user一个实例交互:

基本模块 – 获得inheritance:

 /** * Base module */ 'use strict'; const _ = require("underscore"); module.exports = { name: "base", /** * Extent object helper */ extend: function(child) { return _.extend({}, this, child); }, /** * Delegate event method */ delegate: function () { //some delegate event } }; 

用户模块 – 像一个模型:

 /** * User module */ 'use strict'; const BaseController = require("./base"); module.exports = BaseController.extend({ name: "user", /** * Init function */ init: function() { } }); 

处理程序 – 像一个控制器:

 /** * Handler module */ 'use strict'; const user = require("./user"); module.exports = { name: "handler", /** * Some action */ someAction: function() { user.delegate(); // <-- delegate() is not known as a method of "user" } }; 

代码中的重要部分用注释标记// <-- delegate() is not known as a method of "user"因为它由base模块inheritance。 我真的很想知道如何创build一个完整的JSDoc在这个模块,使我的IDE支持自动完成我的代码,特别是user.delegate() 。 提供所有必须的JSDoc块的答案应该是一个很大的交易!

你可以看看@inheritdoc指令:

 /** * @classdesc Abstract class representing a network connection. * @class */ function Connection() {} /** * Open the connection. */ Connection.prototype.open = function() { // ... }; /** * @classdesc Class representing a socket connection. * @class * @augments Connection */ function Socket() {} /** @inheritdoc */ Socket.prototype.open = function() { // ... }; 

所以, 针对你的具体情况

 /** * @class * @augments Base **/ module.exports = { name: 'User' };