Search code examples
javascriptreactjsvisual-studio-codetsdoc

TSdoc for functions in interfaces


I am having issues with documenting my functions when they come from interfaces. (This is a react app)

here's a visual example of my problem:

export interface IUserContext {
  /**
   * The call signature for `OnLeave`.
   * @param success - true if successful
   */
  onLeave: (success: boolean) => Promise<unknown>;
}

this is a somewhat basic and easy interface with some documentation for my function.

When creating my reacte context, I do it like this:

export const UserContext = React.createContext<IUserContext | null>(null);

If you have a look on the picture below, you can see that upon calling that function in another file from my context, the tsdoc does not correspond.enter image description here

@param is missing. When trying with other tagsn none of them appear...

Anyone knows what is going on?


Solution

  • I found a solution to my own question after all.

    The problem comes from destructuring the returned value from the "useUser" context. I still have to look up a bit more to understand why. But if you stumble upon the same problem, do not destructure the returned value and everything is going to be ok :-)