微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jsDoc:Class构造函数的src行号指向Class声明,而不是构造函数

如何解决jsDoc:Class构造函数的src行号指向Class声明,而不是构造函数

我喜欢将静态方法放在类的顶部,然后是ctor和方法

但是该类的构造函数的jsDoc行号指向该类的顶部,而不是构造函数。即使使用@constructor也无济于事。

有没有办法强迫jsDoc指向ctor,而不是类声明?

Ex:源文件

import util from './util.js'

/**
 * Subclass of Array with convenience methods used by Netlogo.
 * Typically the items in the array are Objects but can be any type.
 */
class AgentArray extends Array {
  /**
   * Convert an existing Array to an AgentArray "in place".
   * Use array.slice() if a new array is wanted
   *
   * @static
   * @param {Array} array Array to convert to AgentArray
   * @return {AgentArray} array converted to AgentArray
   */
  static fromArray(array) {
      const aarray = Object.setPrototypeOf(array,AgentArray.prototype)
      return aarray
  }

  /**
   * Creates an instance of AgentArray. Simply pass-through to super()
   * Now,but may add initialization code later.
   * @param {*} args Zero or more items in Array
   * @example
   * let aa = new AgentArray({x:0,y:0},{x:0,y:1},{x:1,y:0})
   *  //=>  [{ x: 0,y: 0 },{ x: 0,y: 1 },{ x: 1,y: 0 }]
   */
  constructor(...args) {
      super(...args)
      // maybe do some initialization later
  }

}

jsDoc html文件

enter image description here

请注意,ctor位于第7行..这是:

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。