October 22, 2024
Chicago 12, Melborne City, USA
javascript

How can I have a JSDoc interface with static properties & methods?


The following is an interface.

/**
 * @interface
 */
class ISomething {
  /**
   * @return {number}
   */
  static aMethod() {
    throw new Error('not implemented');
  }

  /**
   * @type {Object}
   */
  static property;
}

The following is an implementation, and no errors happen if I don’t add the static items.

/**
 * @implements {ISomething}
 */
class Implementation {
  // forgot to implement the static items
  // no errors in VSCode
}

What I want is to similar to how interfaces work but for static items that can be accessed with respect to the class instead of object. I want some error if I forget to implement a static method. Any workarounds and hacks are appreciated.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video