How to use JSDoc annotations in indexed types

Viewed 50

I have a Tables type with the nested indexed properties. And I want to indicate what context the object is but JsDoc is not indicating my comments. How do I achieve this?

Here is my code:

type Tables = {
    /**
     * Table name
     */
    [tableName: string]: {
      /**
       * Column name
       */
      [columnName: string]: Properties
    }
  }

I don't know if this is related to my IDE but I was expecting to see the annotation on the tooltip:

ts indexed property comment

1 Answers

The following should work:

type Tables = {
  [
    /**
     * Table name
     */
    tableName: string
  ]: {
    [
      /**
       * Column name
       */
      columnName: string
    ]: string
  }
}

enter image description here

enter image description here

Related