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

[Card] Fix TypeScript not recognizing "component" prop #20093

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b1fa650
Fix CardHeader breaking when `titleTypographyProps` or `subheaderTypo…
rart Mar 13, 2020
87e1daf
Update fix to be done at lowest level
rart Mar 13, 2020
e89ddfd
[Autocomplete] Simplify error for wrong getOptionLabel (#20103)
oliviertassinari Mar 13, 2020
35dae27
[Select] Simplify the demos (remove ref) (#20076)
captain-yossarian Mar 13, 2020
e822f3a
Making component prop optional
rart Mar 15, 2020
da3fd22
Using generic type for optional component prop.
rart Mar 15, 2020
1c7965a
[ci] Fix azure not running (#20127)
eps1lon Mar 15, 2020
223cbf3
[Autocomplete] Document listbox limitation (#20101)
zatine Mar 15, 2020
ab228e4
[Autocomplete] Fix typo in prop description (#20086)
vince1995 Mar 15, 2020
eb1529f
[Security] Bump acorn from 5.7.3 to 5.7.4 (#20105)
dependabot-preview[bot] Mar 15, 2020
8cf0fb7
[core] Improve the DX when iterating on components (#20128)
oliviertassinari Mar 15, 2020
468474a
Bump @testing-library/dom from 6.15.0 to 7.0.3 (#20113)
dependabot-preview[bot] Mar 15, 2020
5864e08
Bump sinon from 9.0.0 to 9.0.1 (#20119)
dependabot-preview[bot] Mar 15, 2020
798cf28
Bump rollup-plugin-terser from 5.2.0 to 5.3.0 (#20120)
dependabot-preview[bot] Mar 15, 2020
b023308
[Autocomplete] Fix clearOnEscape + multiple combination (#20065)
chaudharykiran Mar 15, 2020
a94ad0c
Bump date-fns from 2.10.0 to 2.11.0 (#20118)
dependabot-preview[bot] Mar 15, 2020
75fbb26
Bump yargs from 15.2.0 to 15.3.0 (#20114)
dependabot-preview[bot] Mar 15, 2020
383175a
Bump jsdom from 16.2.0 to 16.2.1 (#20123)
dependabot-preview[bot] Mar 15, 2020
bd8a9b1
Bump danger from 9.2.10 to 9.3.0 (#20117)
dependabot-preview[bot] Mar 15, 2020
dc27bd2
Bump webpack-bundle-analyzer from 3.6.0 to 3.6.1 (#20122)
dependabot-preview[bot] Mar 15, 2020
f32c94e
Use generic type for optional component prop.
rart Mar 15, 2020
7285bbd
Bump @types/chai from 4.2.10 to 4.2.11 (#20116)
dependabot-preview[bot] Mar 15, 2020
2170e67
Use generic type for optional component prop.
rart Mar 15, 2020
6fcefc4
Bump eslint-config-airbnb from 17.1.1 to 18.1.0 (#20124)
dependabot-preview[bot] Mar 15, 2020
f27c78f
[Autocomplete] Fix GitHub's demo behavior (#19928)
hasanozacar Mar 15, 2020
93ef218
[AvatarGroup] Add max avatar prop (#19853)
GFynbo Mar 16, 2020
70c937d
[styles] Fix theme default props overriden by Component defaul… (#20091)
adridavid Mar 16, 2020
294760f
[docs] Display color preview in IntelliSense (#20079)
eps1lon Mar 16, 2020
836b11e
[core] Batch small changes (#20111)
oliviertassinari Mar 16, 2020
7c47bf6
[docs] Fix SEO issues (#20108)
oliviertassinari Mar 16, 2020
1d20156
[Skeleton] Improve wave dark mode support (#20112)
oliviertassinari Mar 16, 2020
bbcc43d
[core] Fix deepmerge of DOM elements (#20100)
ValentinH Mar 16, 2020
701e3ad
[core] Update type defs to use OverridableComponent (#20110)
Mar 16, 2020
16b72d7
Clean test code from unessential comments and annotations
rart Mar 17, 2020
eec5e1a
[docs] Simplify drawer examples (#20040)
TommyJackson85 Mar 17, 2020
b49804c
[Autocomplete] Make categories more obvious (#20142)
embeddedt Mar 17, 2020
27d2a62
Bump @testing-library/react from 9.5.0 to 10.0.1 (#20121)
dependabot-preview[bot] Mar 17, 2020
7d23542
[core] Fix docs:api cleaning the wrong directory (#20164)
ro7584 Mar 18, 2020
0176a23
v4.9.6
oliviertassinari Mar 18, 2020
db2865a
[docs] Add select prop to TextField example (#20167)
vince1995 Mar 18, 2020
276b8ff
[test] Restore nextjs cache for size snapshot (#20155)
eps1lon Mar 18, 2020
10bc98f
[core] Patch correct dependencies
oliviertassinari Mar 18, 2020
4fe9051
[ListItemText] Add comonent prop to primaryTypographyProps and… (#19155)
fyodore82 Mar 18, 2020
a3cc7e5
[ListItemText] Add JSDOC to typescript props (#20171)
eps1lon Mar 18, 2020
f1831df
[docs] Link to demos and API in IntelliSense (#20078)
eps1lon Mar 18, 2020
261da95
[WIP] Add CardHeader types and tests for nested typography components…
rart Mar 19, 2020
968b06b
Merge remote-tracking branch 'roy/fix-nested-typography-prop-componen…
rart Mar 19, 2020
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
45 changes: 45 additions & 0 deletions packages/material-ui/src/CardHeader/CardHeader.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import CardHeader from '@material-ui/core/CardHeader';

declare var yada: () => void;

const CardHeaderTest = () => {
const FunctionComponent: React.FC<{ prop1: string; prop2: number }> = () => <div />;
function notAnElementType(): void {
yada();
}
function SimpleFunctionComponent() {
return <div />;
}
return (
<div>
<CardHeader />
<CardHeader
titleTypographyProps={{ align: 'center' }}
subheaderTypographyProps={{ align: 'center' }}
/>
<CardHeader
titleTypographyProps={{ align: 'center', component: 'h1' }}
subheaderTypographyProps={{ align: 'center', component: 'p' }}
/>
<CardHeader
titleTypographyProps={{ align: 'center', component: FunctionComponent }}
subheaderTypographyProps={{ align: 'center', component: FunctionComponent }}
/>
<CardHeader
titleTypographyProps={{ align: 'center', component: SimpleFunctionComponent }}
subheaderTypographyProps={{ align: 'center', component: SimpleFunctionComponent }}
/>
// $ExpectError
<CardHeader
titleTypographyProps={{ align: 'center', component: notAnElementType }}
subheaderTypographyProps={{ align: 'center', component: notAnElementType }}
/>
// $ExpectError
<CardHeader
titleTypographyProps={{ align: 'center', component: 'my-element' }}
subheaderTypographyProps={{ align: 'center', component: 'my-element' }}
/>
</div>
);
};
46 changes: 46 additions & 0 deletions packages/material-ui/src/ListItemText/ListItemText.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import ListItemText from '@material-ui/core/ListItemText';

declare var yada: () => void;

const ListItemTextTest = () => {
const FunctionComponent: React.FC<{ prop1: string; prop2: number }> = () => <div />;
function notAnElementType(): void {
yada();
}
function SimpleFunctionComponent() {
return <div />;
}
return (
<div>
<ListItemText />
<ListItemText disableTypography />
<ListItemText
primaryTypographyProps={{ align: 'center' }}
secondaryTypographyProps={{ align: 'center' }}
/>
<ListItemText
primaryTypographyProps={{ align: 'center', component: 'h1' }}
secondaryTypographyProps={{ align: 'center', component: 'p' }}
/>
<ListItemText
primaryTypographyProps={{ align: 'center', component: FunctionComponent }}
rart marked this conversation as resolved.
Show resolved Hide resolved
secondaryTypographyProps={{ align: 'center', component: FunctionComponent }}
/>
<ListItemText
primaryTypographyProps={{ align: 'center', component: SimpleFunctionComponent }}
secondaryTypographyProps={{ align: 'center', component: SimpleFunctionComponent }}
/>
// $ExpectError
<ListItemText
primaryTypographyProps={{ align: 'center', component: notAnElementType }}
secondaryTypographyProps={{ align: 'center', component: notAnElementType }}
/>
// $ExpectError
<ListItemText
primaryTypographyProps={{ align: 'center', component: 'my-element' }}
secondaryTypographyProps={{ align: 'center', component: 'my-element' }}
/>
</div>
);
};
5 changes: 3 additions & 2 deletions packages/material-ui/src/Typography/Typography.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { StandardProps, PropTypes } from '..';
import { OverrideProps, OverridableTypeMap, OverridableComponent } from '../OverridableComponent';
import { PropTypes } from '..';
import { OverrideProps, OverridableComponent } from '../OverridableComponent';
import { Variant as ThemeVariant } from '../styles/createTypography';

type Variant = ThemeVariant | 'srOnly';
Expand All @@ -22,6 +22,7 @@ export interface TypographyTypeMap<P = {}, D extends React.ElementType = 'span'>
paragraph?: boolean;
variant?: Variant | 'inherit';
variantMapping?: Partial<Record<Variant, string>>;
component?: React.ElementType;
rart marked this conversation as resolved.
Show resolved Hide resolved
};
defaultComponent: D;
classKey: TypographyClassKey;
Expand Down