我正在创建一个用于谷歌应用程序脚本的库,并且在使用JSDoc 样式文档时遇到了一些问题,以便 IDE 自动完成功能适用于最终用户。
作为 User.prototype.METHODNAME 输入的所有方法都应显示在此库的自动完成中。目前只有 .getEmail() 方法出现在用户对象的自动完成中。.getName() .getPassword() .hasPaid() 等方法也应该出现,但不会出现。特别奇怪的是,当我交换 .getEmail() 和 .getId() 的方法名称(并且只有方法名称)时,IDE 仍然显示 .getEmail() 作为唯一选项,并运行原始的 .getId() 方法.
这是一个模拟库的库密钥,没有用于测试的敏感信息:M1TqnX8hyIa1H8ikAojXirsqqTKXVxxXC
/**
*@param {Number} id
*@param {String} email
*@param {String} name
*@param {String} password
*@return {User} User
*/
function User(id, email, name, password){
var ss = SpreadsheetApp.openById("INSERT SPREADSHEET HERE").getSheetByName("Users");
var data = ss.getRange(1, 1, ss.getLastRow(), ss.getLastColumn()).getValues();
for (var i = 1; i < data.length; i++){
if (data[i][0] == id){
this.id = id;
this.email = data[i][1];
this.name = data[i][2];
this.password = data[i][3];
this.picks = data[i][4];
this.paid = data[i][5];
}
}
return this;
}
/**
* @param {Number} id ID of the user
* @return {User} User
*/
function getUserById(id){
var user = new User(id, null, null, null);
return user;
}
/**
* @param {String} email email of the user
* @param {String} name name of the user
* @return {User} User
*/
function getUserByEmailAndName(email, name){
return new User(null, email, name, null);
}
/**
*@return {Boolean} isCorrect
*/
User.prototype.checkPassword = function (password){ return this.password == Utilities.base64Encode(password); }
User.prototype.getEmail = function (){return this.email;}
/**
*@return {Number} id
*/
User.prototype.getId = function (){return this.id;}
/**
*@return {String} name
*/
User.prototype.getName = function (){return this.name;}
/**
*@return {String} encodedPassword
*/
User.prototype.getPassword = function (){return this.password;}
/**
*@return {String} jsonPicks
*/
User.prototype.getPicksAsString = function (){return this.picks;}
/**
*@return {JSON} jsonPicks
*/
User.prototype.getPicksAsJson = function (){return Utilities.jsonParse(this.picks);}
/**
*@return {Boolean} hasPaid
*/
User.prototype.hasPaid = function (){return this.paid;}