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

[DialogContentText] Fix component prop #19102

Merged
merged 1 commit into from
Jan 9, 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
20 changes: 16 additions & 4 deletions packages/material-ui/src/DialogContentText/DialogContentText.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import * as React from 'react';
import { StandardProps } from '..';
import { TypographyProps } from '../Typography';
import { TypographyTypeMap } from '../Typography';
import { OverrideProps, OverridableTypeMap, OverridableComponent } from '../OverridableComponent';

export interface DialogContentTextProps
extends StandardProps<TypographyProps, DialogContentTextClassKey> {}
export interface DialogContentTextTypeMap<
P = {},
D extends React.ElementType = TypographyTypeMap['defaultComponent']
> {
props: P & TypographyTypeMap['props'];
defaultComponent: D;
classKey: DialogContentTextClassKey;
}

export type DialogContentTextClassKey = 'root';

declare const DialogContentText: React.ComponentType<DialogContentTextProps>;
declare const DialogContentText: OverridableComponent<DialogContentTextTypeMap>;

export type DialogContentTextProps<
D extends React.ElementType = DialogContentTextTypeMap['defaultComponent'],
P = {}
> = OverrideProps<DialogContentTextTypeMap<P, D>, D>;

export default DialogContentText;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { FC } from 'react';
import { DialogContentText } from '@material-ui/core';

const DialogContentTextTest = () => {
const CustomComponent: React.FC<{ prop1: string; prop2: number }> = () => <div />;
return (
<div>
<DialogContentText />
<DialogContentText classes={{ root: 'rootClass' }} />
// $ExpectError
<DialogContentText classes={{ body1: 'body1Class' }} />
<DialogContentText align="inherit" color="inherit" display="block" />
<DialogContentText align="left" color="initial" display="inline" />
<DialogContentText align="right" color="primary" display="initial" />
<DialogContentText align="justify" color="secondary" display="initial" />
<DialogContentText align="inherit" color="textPrimary" />
<DialogContentText align="inherit" color="textSecondary" />
<DialogContentText align="inherit" color="error" />
// $ExpectError
<DialogContentText display="incorrectValue" />
<DialogContentText component="a" href="url" display="block" />
<DialogContentText component="label" htmlFor="html" display="block" />
// $ExpectError
<DialogContentText component="a" href="url" display="incorrectValue" />
// $ExpectError
<DialogContentText component="a" incorrectAttribute="url" />
// $ExpectError
<DialogContentText component="incorrectComponent" href="url" />
// $ExpectError
<DialogContentText component="div" href="url" />
// $ExpectError
<DialogContentText href="url" />
<DialogContentText component={CustomComponent} prop1="1" prop2={12} />
// $ExpectError
<DialogContentText component={CustomComponent} prop1="1" prop2={12} id="1" />
// $ExpectError
<DialogContentText component={CustomComponent} prop1="1" />
// $ExpectError
<DialogContentText component={CustomComponent} prop1="1" prop2="12" />
</div>
);
};