Material-ui: [Slide] Wrong direction TypeScript definition

Created on 12 Mar 2020  路  9Comments  路  Source: mui-org/material-ui


Please see: https://material-ui.com/api/slide/

The docs say the direction prop has a default value of "down", but if you omit it from real code, the type information will complain saying you didn't specify the direction prop.

Either the doc or the type info is wrong.

  • [ x] The issue is present in the latest release.
  • [ x] I have searched the issues of this repository and believe that this is not a duplicate.

Your Environment 馃寧

| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.9.5 |
| React | |
| Browser | |
| TypeScript | |
| etc. | |

bug 馃悰 Transition good first issue typescript

All 9 comments

Please provide a full reproduction test case. This would help a lot 馃懛 .
A live example would be perfect. This codesandbox.io template _may_ be a good starting point. Thank you!

Looking at the source, it seems about right

https://github.com/mui-org/material-ui/blob/7102777b6d248e9b23740a629781726f725019c7/packages/material-ui/src/Slide/Slide.d.ts#L6

Do you want to take care of the problem? :)

@wmitsuda I believe the fix would look like this:

diff --git a/packages/material-ui/src/Slide/Slide.d.ts b/packages/material-ui/src/Slide/Slide.d.ts
index 77efeeb8d..6132d95e1 100644
--- a/packages/material-ui/src/Slide/Slide.d.ts
+++ b/packages/material-ui/src/Slide/Slide.d.ts
@@ -3,7 +3,7 @@ import { Theme } from '../styles/createMuiTheme';
 import { TransitionProps } from '../transitions/transition';

 export interface SlideProps extends TransitionProps {
-  direction: 'left' | 'right' | 'up' | 'down';
+  direction?: 'left' | 'right' | 'up' | 'down';
   ref?: React.Ref<unknown>;
   theme?: Theme;
 }

@oliviertassinari were you able to reproduce this problem? I'm willing to take care of that, but I have not been able to reproduce it.

I haven't tried to reproduce it. I have only looked at the source that looked wrong.

:thinking: @wmitsuda could you provide more details?

@belgamo if you go to this slide example at Material-UI doc and remove
direction="up", Typescript will throw an error. look here at codesandbox

What @oliviertassinari said solves the problem.

@wmitsuda I believe the fix would look like this:

I can create a PR for this issue. I'm looking to get more involved in the open source community, and love material-ui; would love to give back to the community :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sys13 picture sys13  路  3Comments

mb-copart picture mb-copart  路  3Comments

finaiized picture finaiized  路  3Comments

mattmiddlesworth picture mattmiddlesworth  路  3Comments

rbozan picture rbozan  路  3Comments