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

Continuation of Flow updates 0.57+ #9203

Merged
merged 11 commits into from Nov 20, 2017
Merged

Conversation

rosskevin
Copy link
Member

@rosskevin rosskevin commented Nov 17, 2017

Closes #9222

This is a follow-on for #8983 by @rsolomon

Now that flow's treatment of defaultProps changed with flow 0.57.0, we no longer need to specify type DefaultProps separate from type Props.

The only quirk is that sometimes when a defaultProp is a union, it needs to be cast to the type specified in type Props, as it doesn't seem to be able to resolve it. Regardless, overall, it's a cut in code and due to reduced duplication.

Also, since type Props is the single source of truth, I have fixed the maybe types that were missing in #8983 (due to the difficulty of duplicating these properties in both Props and DefaultProps)

Regarding SwitchBase, it was used as a typical Component in all but Radio, and even in Radio, it was effectively used as a normal component there. It raised some stateless function flow errors so I simply removed the factory wrapper and exposed the underlying SwitchBase, it left usage virtually unchanged.

@oliviertassinari
Copy link
Member

A sample of the API diff it's introducing:

 | Name | Type | Default | Description |
 |:-----|:-----|:--------|:------------|
 | classes | Object |  | Useful to extend the style applied to components. |
-| <span style="color: #31a148">component *</span> | ElementType | 'div' | The component used for the root node. Either a string to use a DOM element or a component. |
+| <span style="color: #31a148">component *</span> | ElementType | 'div': ElementType | The component used for the root node. Either a string to use a DOM element or a component. |

I'm wondering if we can avoid 'div': ElementType. Any idea?

@rosskevin
Copy link
Member Author

I'm wondering if we can avoid 'div': ElementType. Any idea?

I think we'll have to hack off the flow type cast when we process it.

@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Nov 18, 2017
@rosskevin rosskevin changed the title Remove type DefaultProps Continuation of Flow updates 0.57+ Nov 18, 2017
@rosskevin rosskevin added the on hold There is a blocker, we need to wait label Nov 20, 2017
@rosskevin rosskevin removed PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI on hold There is a blocker, we need to wait labels Nov 20, 2017
…to flow-defaultprops

# Conflicts:
#	pages/api/dialog.md
#	pages/api/drawer.md
#	pages/api/fade.md
#	pages/api/grid.md
#	pages/api/slide.md
#	pages/api/snackbar.md
@rosskevin
Copy link
Member Author

With this PR, docs should be back to normal. We are now on a temp branch package @rosskevin/react-docgen.

I have put in an issue for that.

@rosskevin rosskevin merged commit c146887 into mui:v1-beta Nov 20, 2017
@rosskevin rosskevin deleted the flow-defaultprops branch November 20, 2017 02:08
@@ -34,6 +34,9 @@ export type Color = 'inherit' | 'accent' | 'action' | 'contrast' | 'disabled' |

type ProvidedProps = {
classes: Object,
/**
* @ignore
*/
theme?: Object,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been wondering, why to we put the theme here in the first place? I have noticed we can remove them with no flow issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can remove them now with @rsolomon's latest PR to react-flow-types, we should do that.

@oliviertassinari
Copy link
Member

@rosskevin Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants