RequireJS导入文档
我在WebStorm编辑器中使用。我的项目是使用AMD的RequireJS。下面是一个代码示例: dep.jsRequireJS导入文档,requirejs,webstorm,jsdoc,Requirejs,Webstorm,Jsdoc,我在WebStorm编辑器中使用。我的项目是使用AMD的RequireJS。下面是一个代码示例: dep.js define([], function () { var exports = { helloWorld: function() { console.log("Hello world"); } }; return exports; }); define(['dep'], function (dep) { var exports = { sayHello: func
define([], function () {
var exports = {
helloWorld: function() {
console.log("Hello world");
}
};
return exports;
});
define(['dep'], function (dep) {
var exports = {
sayHello: function() {
dep.helloWorld();
}
};
return exports;
});
primary.js
define([], function () {
var exports = {
helloWorld: function() {
console.log("Hello world");
}
};
return exports;
});
define(['dep'], function (dep) {
var exports = {
sayHello: function() {
dep.helloWorld();
}
};
return exports;
});
如何正确记录此类AMD模块的导出(主要在其他答案中描述)和导入(重要!),以便WebStorm可以对导入的dep(如本例中的“dep”变量)提供正确的类型提示。根据,它应该是smth类的
/**
* @module dep
*/
define([], function() {
/**
* @constructor
* @alias module:dep
*/
var exports = {
helloWorld: function() {
console.log("Hello world");
}
};
return exports;
});
我主要对进口评论感兴趣。导出注释在其他问题中有很好的解释,但它们不能帮助WebStorm查看导入模块的正确类型。