You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Apps Script库类方法无自动补全的原因排查与解决

Google Apps Script库类方法自动补全失效问题及解决办法

问题背景

我创建了一个无容器绑定的Google Apps Script,编写了如下代码并将其部署为库:

/** 
 * @class
 */
class Table5 {

  constructor(ss_id){
    this.ss_id = ss_id;
  }

  /**
   * GetSheet5
   * @param {string} sheet_id - sheet id
   * @memberof Table5#
   */
  GetSheet5(sheet_id){
    console.log(`ss_id="${this.ss_id}", sheet_id="${sheet_id}"`)
  }
}

/**
 * Table5
 * @constructs
 * @param {string} ss_id - ss_id
 */
let new_point = (ss_id) => new Table5(ss_id)

问题现象

在应用代码中调用MyLib.new_point().后,预期会显示类方法的提示或自动补全,但实际并未出现。脚本内部调用时正常显示提示,但作为库调用时无提示,推测是JSDoc标签使用不当,导致类原型函数无法被识别从而无法触发自动补全。

解决方法

调整JSDoc标签后功能恢复正常,核心是为new_point添加@return标签明确返回Table5类型,同时调整了类相关的JSDoc标签。修正后的代码如下:

/** @lends new_point.prototype */
class Table5 {

  /** @constructor */
  constructor(ss_id){
    this.ss_id = ss_id;
  }

  /**
   * GetSheet5
   * @memberof Table5#
   * @param {string} sheet_id - sheet id
   */
  GetSheet5(sheet_id){
    console.log(`ss_id="${this.ss_id}", sheet_id="${sheet_id}"`)
  }

}


/**
 * This is a description of the Table5 constructor function.
 * @class
 * @classdesc This is a description of the Table5 class.
 * @param {string} ss_id - ss_id
 * @return {Table5}
 */
let new_point = (ss_id) => new Table5(ss_id)

内容的提问来源于stack exchange,提问作者Oleg no

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 22:13:35