Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ListItemText] Add JSDOC to typescript props #20171

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a new item in the next batch to rename property -> prop. This is part of https://trello.com/c/AxWGaWEw/1390-replace-property-prop-in-the-react-element-context.

*/
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