Slava.In
Slava.In

Reputation: 1059

How to describe interface method with a type using js docs?

I have the following code:

/**
 * @interface an interface for Foo
 */
interface IFoo {
  init: () => void;
}

class Foo implements IFoo {
  public init(): void {}
}

I want to describe init method with a type like I would for any other param @param {type} name - description, but @param doesn't seem to be a good thing for the method description and the @method can not properly display the type, after trying

 * @method {() => void} init - method for initialization

I get this kind of description:

enter image description here

Is there a proper way for describing interface methods with a type?

Upvotes: 0

Views: 192

Answers (1)

maksimr
maksimr

Reputation: 5429

You can omit @ tags and place description in the comment above method or/and interface

/**
 * An interface for Foo
 */
interface IFoo {
  /**
   * method for initialization
   */
  init: () => void;
}

enter image description here

Upvotes: 1

Related Questions