Skip to content

Commit

Permalink
[ListItemText] Add JSDOC to typescript props
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 18, 2020
1 parent 4fe9051 commit 3ecd657
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
39 changes: 30 additions & 9 deletions packages/material-ui/src/ListItemText/ListItemText.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,42 @@ export interface ListItemTextProps<
PrimaryTypographyComponent extends React.ElementType = 'span',
SecondaryTypographyComponent extends React.ElementType = 'p'
> extends StandardProps<React.HTMLAttributes<HTMLDivElement>, ListItemTextClassKey> {
/**
* Alias for the `primary` property.
*/
children?: React.ReactNode;
/**
* If `true`, the children won't be wrapped by a Typography component.
* This can be useful to render an alternative Typography variant by wrapping
* the `children` (or `primary`) text, and optional `secondary` text
* with the Typography component.
*/
disableTypography?: boolean;
/**
* If `true`, the children will be indented.
* This should be used if there is no left avatar or left icon.
*/
inset?: boolean;
/**
* The main content element.
*/
primary?: React.ReactNode;
/**
* These props will be forwarded to the primary typography component
* (as long as disableTypography is not `true`).
*/
primaryTypographyProps?: TypographyProps<
PrimaryTypographyComponent,
{ component?: PrimaryTypographyComponent }
>;
/**
* The secondary content element.
*/
secondary?: React.ReactNode;
/**
* These props will be forwarded to the secondary typography component
* (as long as disableTypography is not `true`).
*/
secondaryTypographyProps?: TypographyProps<
SecondaryTypographyComponent,
{ component?: SecondaryTypographyComponent }
Expand All @@ -28,14 +56,7 @@ export type ListItemTextClassKey =
| 'primary'
| 'secondary';

// If use function instead const, yarn proptypes (scripts/generateProptypes.ts) will overwrite ListItemText.js with proptypes from current file.
// const declarations are ignored.
/* tslint:disable:prefer-declare-function */
declare const ListItemText: <
export default function ListItemText<
PrimaryTypographyComponent extends React.ElementType = 'span',
SecondaryTypographyComponent extends React.ElementType = 'p'
>(
props: ListItemTextProps<PrimaryTypographyComponent, SecondaryTypographyComponent>,
) => JSX.Element;

export default ListItemText;
>(props: ListItemTextProps<PrimaryTypographyComponent, SecondaryTypographyComponent>): JSX.Element;
6 changes: 5 additions & 1 deletion packages/material-ui/src/ListItemText/ListItemText.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const ListItemText = React.forwardRef(function ListItemText(props, ref) {
});

ListItemText.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* Alias for the `primary` property.
*/
Expand All @@ -104,7 +108,7 @@ ListItemText.propTypes = {
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object.isRequired,
classes: PropTypes.object,
/**
* @ignore
*/
Expand Down

0 comments on commit 3ecd657

Please sign in to comment.