react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Adding description to types

Open simcha90 opened this issue 1 year ago • 2 comments

Can we add types description for React types, that can be supported for docs generators?

For example we use next inheritance:

import React, { ButtonHTMLAttributes, FC } from 'react'

export interface ActionIconProps
  extends Pick<
      ButtonHTMLAttributes<HTMLButtonElement>,
      | 'title'
      | 'tabIndex'
      | 'className'
      | 'style'
      | 'aria-label'
      | 'aria-haspopup'
      | 'aria-expanded'
      | 'onClick'
      | 'onKeyDown'
      | 'onMouseDown'
      | 'onFocus'
      | 'onBlur'
      | 'disabled'
    > {
  /** My custom property */
  myProp: string
}

and in doc system like Storybook it generated without description.

simcha90 avatar Jan 21 '24 07:01 simcha90

What do you think @eps1lon

rickhanlonii avatar Jan 22 '24 21:01 rickhanlonii

We do have it in some places not every case. I'm all for adding more JSDOC to the React types.

I'm currently more occupied with cleaning up a lot of old code from the types. When I see low-hanging fruit, I definitely add docs.

In the meantime you could always add docs to the types where you think it would be helpful: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts

PS: I'm unassigning myself mainly so that people don't think they can't contribute to this issue. It's really a bigger effort that can be done by multiple people.

eps1lon avatar Jan 23 '24 09:01 eps1lon