Skip to content

Commit

Permalink
[core] Fix incorrect typings regarding transition components a… (#20306)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Mar 27, 2020
1 parent 7c66428 commit 74625ab
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 11 deletions.
5 changes: 4 additions & 1 deletion docs/src/pages/components/dialogs/AlertDialogSlide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import DialogTitle from '@material-ui/core/DialogTitle';
import Slide from '@material-ui/core/Slide';
import { TransitionProps } from '@material-ui/core/transitions';

const Transition = React.forwardRef<unknown, TransitionProps>(function Transition(props, ref) {
const Transition = React.forwardRef(function Transition(
props: TransitionProps & { children?: React.ReactElement<any, any> },
ref: React.Ref<unknown>,
) {
return <Slide direction="up" ref={ref} {...props} />;
});

Expand Down
5 changes: 4 additions & 1 deletion docs/src/pages/components/dialogs/FullScreenDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const useStyles = makeStyles((theme: Theme) =>
}),
);

const Transition = React.forwardRef<unknown, TransitionProps>(function Transition(props, ref) {
const Transition = React.forwardRef(function Transition(
props: TransitionProps & { children?: React.ReactElement },
ref: React.Ref<unknown>,
) {
return <Slide direction="up" ref={ref} {...props} />;
});

Expand Down
5 changes: 3 additions & 2 deletions docs/src/pages/components/snackbars/DirectionSnackbar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import Snackbar from '@material-ui/core/Snackbar';
import Slide from '@material-ui/core/Slide';
import { TransitionProps } from '@material-ui/core/transitions';
import Slide, { SlideProps } from '@material-ui/core/Slide';

type TransitionProps = Omit<SlideProps, 'direction'>;

function TransitionLeft(props: TransitionProps) {
return <Slide {...props} direction="left" />;
Expand Down
6 changes: 4 additions & 2 deletions docs/src/pages/components/snackbars/TransitionsSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ function GrowTransition(props: TransitionProps) {
export default function TransitionsSnackbar() {
const [state, setState] = React.useState<{
open: boolean;
Transition: React.ComponentType<TransitionProps>;
Transition: React.ComponentType<TransitionProps & { children?: React.ReactElement<any, any> }>;
}>({
open: false,
Transition: Fade,
});

const handleClick = (Transition: React.ComponentType<TransitionProps>) => () => {
const handleClick = (
Transition: React.ComponentType<TransitionProps & { children?: React.ReactElement<any, any> }>,
) => () => {
setState({
open: true,
Transition,
Expand Down
4 changes: 3 additions & 1 deletion packages/material-ui/src/Dialog/Dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export interface DialogProps
* The component used for the transition.
* [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
*/
TransitionComponent?: React.ComponentType<TransitionProps>;
TransitionComponent?: React.ComponentType<
TransitionProps & { children?: React.ReactElement<any, any> }
>;
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
Expand Down
4 changes: 3 additions & 1 deletion packages/material-ui/src/ExpansionPanel/ExpansionPanel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export interface ExpansionPanelProps
disabled?: boolean;
expanded?: boolean;
onChange?: (event: React.ChangeEvent<{}>, expanded: boolean) => void;
TransitionComponent?: React.ComponentType<TransitionProps>;
TransitionComponent?: React.ComponentType<
TransitionProps & { children?: React.ReactElement<any, any> }
>;
TransitionProps?: TransitionProps;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/material-ui/src/Popover/Popover.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export interface PopoverProps
PaperProps?: Partial<PaperProps>;
role?: string;
transformOrigin?: PopoverOrigin;
TransitionComponent?: React.ComponentType<TransitionProps>;
TransitionComponent?: React.ComponentType<
TransitionProps & { children?: React.ReactElement<any, any> }
>;
transitionDuration?: TransitionProps['timeout'] | 'auto';
TransitionProps?: TransitionProps;
}
Expand Down
1 change: 1 addition & 0 deletions packages/material-ui/src/Slide/Slide.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Theme } from '../styles/createMuiTheme';
import { TransitionProps } from '../transitions/transition';

export interface SlideProps extends TransitionProps {
children?: React.ReactElement<any, any>;
direction: 'left' | 'right' | 'up' | 'down';
ref?: React.Ref<unknown>;
theme?: Theme;
Expand Down
4 changes: 3 additions & 1 deletion packages/material-ui/src/Snackbar/Snackbar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ export interface SnackbarProps
* The component used for the transition.
* [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
*/
TransitionComponent?: React.ComponentType<TransitionProps>;
TransitionComponent?: React.ComponentType<
TransitionProps & { children?: React.ReactElement<any, any> }
>;
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
Expand Down
4 changes: 3 additions & 1 deletion packages/material-ui/src/Tooltip/Tooltip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export interface TooltipProps
| 'top';
PopperProps?: Partial<PopperProps>;
title: React.ReactNode;
TransitionComponent?: React.ComponentType<TransitionProps>;
TransitionComponent?: React.ComponentType<
TransitionProps & { children?: React.ReactElement<any, any> }
>;
TransitionProps?: TransitionProps;
}

Expand Down

0 comments on commit 74625ab

Please sign in to comment.