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

[utils] Fix types of chainPropTypes #23123

Merged
merged 2 commits into from
Oct 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
8 changes: 4 additions & 4 deletions packages/material-ui-utils/src/chainPropTypes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import PropTypes from 'prop-types';

export default function chainPropTypes(
propType1: PropTypes.Validator<unknown>,
propType2: PropTypes.Validator<unknown>,
): PropTypes.Validator<unknown> {
export default function chainPropTypes<A, B>(
propType1: PropTypes.Validator<A>,
propType2: PropTypes.Validator<B>,
): PropTypes.Validator<A & B> {
if (process.env.NODE_ENV === 'production') {
return () => null;
}
Expand Down
17 changes: 17 additions & 0 deletions packages/material-ui-utils/src/chainpropTypes.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import chainPropTypes from './chainPropTypes';

interface ChainProps {
foo?: boolean;
}

const Chain: React.FC<ChainProps> = (props) => {
return <div />;
};

Chain.propTypes = {
foo: chainPropTypes(PropTypes.bool, () => {
return null;
}),
};
2 changes: 1 addition & 1 deletion packages/material-ui/src/Box/Box.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';

function responsiveTest() {
function ResponsiveTest() {
<Box p={[2, 3, 4]} />;
<Box p={{ xs: 2, sm: 3, md: 4 }} />;
// undesired
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Grid/Grid.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import * as React from 'react';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';

function responsiveTest() {
function ResponsiveTest() {
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square />;
}