diff --git a/packages/material-ui/src/Typography/Typography.d.ts b/packages/material-ui/src/Typography/Typography.d.ts index a4c300cd3d4725..7b15ba2b8403ff 100644 --- a/packages/material-ui/src/Typography/Typography.d.ts +++ b/packages/material-ui/src/Typography/Typography.d.ts @@ -1,29 +1,39 @@ import * as React from 'react'; import { StandardProps, PropTypes } from '..'; +import { OverrideProps, OverridableTypeMap, OverridableComponent } from '../OverridableComponent'; import { ThemeStyle } from '../styles/createTypography'; type Style = ThemeStyle | 'srOnly'; -export interface TypographyProps - extends StandardProps, TypographyClassKey> { - align?: PropTypes.Alignment; - color?: - | 'initial' - | 'inherit' - | 'primary' - | 'secondary' - | 'textPrimary' - | 'textSecondary' - | 'error'; - component?: React.ElementType>; - display?: 'initial' | 'block' | 'inline'; - gutterBottom?: boolean; - noWrap?: boolean; - paragraph?: boolean; - variant?: Style | 'inherit'; - variantMapping?: Partial>; +export interface TypographyTypeMap

{ + props: P & { + align?: PropTypes.Alignment; + color?: + | 'initial' + | 'inherit' + | 'primary' + | 'secondary' + | 'textPrimary' + | 'textSecondary' + | 'error'; + display?: 'initial' | 'block' | 'inline'; + gutterBottom?: boolean; + noWrap?: boolean; + paragraph?: boolean; + variant?: Style | 'inherit'; + variantMapping?: Partial>; + }; + defaultComponent: D; + classKey: TypographyClassKey; } +declare const Typography: OverridableComponent; + +export type TypographyProps< + D extends React.ElementType = TypographyTypeMap['defaultComponent'], + P = {} +> = OverrideProps, D>; + export type TypographyClassKey = | 'root' | 'h1' @@ -54,6 +64,4 @@ export type TypographyClassKey = | 'displayInline' | 'displayBlock'; -declare const Typography: React.ComponentType; - export default Typography; diff --git a/packages/material-ui/src/Typography/typography.spec.tsx b/packages/material-ui/src/Typography/typography.spec.tsx new file mode 100644 index 00000000000000..7e4eb44e94c2b5 --- /dev/null +++ b/packages/material-ui/src/Typography/typography.spec.tsx @@ -0,0 +1,39 @@ +import React, { FC } from 'react'; +import { Typography } from '@material-ui/core'; + +const TypographyTest = () => { + const CustomComponent: React.FC<{ prop1: string; prop2: number }> = () =>

; + return ( +
+ + + + + + + + + // $ExpectError + + + + // $ExpectError + + // $ExpectError + + // $ExpectError + + // $ExpectError + + // $ExpectError + + + // $ExpectError + + // $ExpectError + + // $ExpectError + +
+ ); +};