How to document nested typescript interfaces for VS Code hints

537 views Asked by At

I am struggling to write a types documentation for a module I'm working on and to get VSCode to show things in hover / intellisense.

Take this example:

/**
 * @description a complex object
 * @property prop1 - a string 
 * @property prop2 - a number argument
 */
interface myObj {
    /** string prop1 */
    prop1: string;
    prop2?: number;
    [key: string]: any
}

interface myfunc {

    /**
     * @description method description
     * @argument foo The first argument
     * @argument {myObj} bar
     */
    some_method: (
        /** simple string argument */
        foo : string,
        /** how to get this to display the description above?  */
        bar : myObj
    ) => void
}

What's working:

  1. Hovering over some_method in either .js or .ts I get the three line description & arg comments
  2. CTRL + SHFIT + SPACE while over the first argument gives me the simple string argument help
  3. Opening an Object as the second argument and hitting CTRL + SPACE suggests prop1 and prop2
  4. Hovering over prop1 inside the second argument gives me string prop1

What isn't working:

The problem I'm having is how do I get the whole description block for myObj displayed when I hit CTRL + SHFIT + SPACE while inside the object of the second argument? It would be super helpful for this kind of argument where there are some predefined properties like prop1 and prop2 but it also allows the user to add any other keys, to have the markdown supported description of myObj displayed.

The moment I add any @ decorators in the comment line above bar : myObj in the myfunc interface VS Code doesn't display anything anymore. And if I want to reuse the myObj interface in other methods, it of course doesn't make sense to use that inline documenting style like simple string argument repeatedly in the code (and it doesn't solve the one line, no markdown problem either).

0

There are 0 answers