From 3ecd65748a79bb9632557f6f8b0cda766640acd1 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Wed, 18 Mar 2020 20:52:07 +0100 Subject: [PATCH] [ListItemText] Add JSDOC to typescript props --- .../src/ListItemText/ListItemText.d.ts | 39 ++++++++++++++----- .../src/ListItemText/ListItemText.js | 6 ++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/packages/material-ui/src/ListItemText/ListItemText.d.ts b/packages/material-ui/src/ListItemText/ListItemText.d.ts index b42832fb37045c..9d5c98b9ee0b57 100644 --- a/packages/material-ui/src/ListItemText/ListItemText.d.ts +++ b/packages/material-ui/src/ListItemText/ListItemText.d.ts @@ -6,14 +6,42 @@ export interface ListItemTextProps< PrimaryTypographyComponent extends React.ElementType = 'span', SecondaryTypographyComponent extends React.ElementType = 'p' > extends StandardProps, 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 } @@ -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, -) => JSX.Element; - -export default ListItemText; +>(props: ListItemTextProps): JSX.Element; diff --git a/packages/material-ui/src/ListItemText/ListItemText.js b/packages/material-ui/src/ListItemText/ListItemText.js index f826e7c5578af1..244b7fabaf2d9c 100644 --- a/packages/material-ui/src/ListItemText/ListItemText.js +++ b/packages/material-ui/src/ListItemText/ListItemText.js @@ -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. */ @@ -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 */