Search code examples
reactjstypescriptvisual-studio-codestyled-componentsjsdoc

How to use JSDoc to document styled components props?


I have tried to document props on vscode with JSDoc multiple times on my custom styled component, but I just can't make it show up in any way.

what shows up for me

I have tried with the following syntax:

/**
 * @param {boolean} testprop - 20px
 */
export const Text``

export interface TextProps {
  /* 20px */ t2?: boolean
}
export const Text<TextProps>``

None of those 2 works so far.

  • Is there any way to make it show up when you hover the prop?
  • What's best practice for this?

Solution

  • This syntax worked for me:

    export interface TextProps {
      /** 20px */ t2?: boolean
    }
    export const Text<TextProps>``
    

    Note that the comment starts with 2 asterisks (/**)

    Now I can hover t2 and get the comment I set before.

    enter image description here enter image description here