-
-
Notifications
You must be signed in to change notification settings - Fork 302
Post process flow default props #231
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
50f7fad
#221 implement post-processor based on code from @adityavohra7
rosskevin 9a837b4
update dependencies - fixes failing react-docgen-test.js locally
rosskevin 8f6f5da
Add flow class test inspired by material-ui usage
rosskevin cc58448
remove any flow type casts in default values
rosskevin 4e93e46
Update snapshot with defaultValue flow type casting post processing
rosskevin c400260
Fix implementation that removes flow default value type cast
rosskevin bb38a5b
better resolve defaultValue as TypeCastExpression
rosskevin 6853250
Add stack too deep case
rosskevin 1cbe42e
simplify node resolution
rosskevin dfe03df
printValue should see through cast
rosskevin be032fd
seeing through TypeCastExpressions works
rosskevin f528630
revert change back to path.node
rosskevin de4fd5c
remove commented line
rosskevin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// @flow | ||
|
||
/** | ||
* Test for documentation of flow class | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { ComponentType, ElementType, Node } from 'react'; | ||
|
||
type ProvidedProps = { | ||
classes: Object, | ||
}; | ||
|
||
export type Origin = { | ||
horizontal: 'left' | 'center' | 'right' | number, | ||
vertical: 'top' | 'center' | 'bottom' | number, | ||
}; | ||
|
||
export const duration = { | ||
standard: 300, | ||
}; | ||
|
||
export type TransitionDuration = number | { enter?: number, exit?: number } | 'auto'; | ||
|
||
export type Props = { | ||
/** | ||
* Other base element props. | ||
*/ | ||
[otherProp: string]: any, | ||
/** | ||
* This is the point on the anchor where the popover's | ||
* `anchorEl` will attach to. This is not used when the | ||
* anchorReference is 'anchorPosition'. | ||
* | ||
* Options: | ||
* vertical: [top, center, bottom]; | ||
* horizontal: [left, center, right]. | ||
*/ | ||
anchorOrigin?: Origin, | ||
/** | ||
* Useful to extend the style applied to components. | ||
*/ | ||
classes?: Object, | ||
/** | ||
* @ignore | ||
*/ | ||
children?: Node, | ||
/** | ||
* The component used for the root node. | ||
* This currently has to be flow cast in defaultProps as of flow 0.59.0 | ||
*/ | ||
component: ElementType, | ||
/** | ||
* Shadow depth, corresponds to `dp` in the spec. | ||
* It's accepting values between 0 and 24 inclusive. | ||
*/ | ||
elevation: number, | ||
/** | ||
* Useful to customize the rows per page label. Invoked with a `{ from, to, count, page }` | ||
* object. | ||
*/ | ||
labelRowsPerPage: Node, | ||
/** | ||
* Transition component. | ||
*/ | ||
transition: ComponentType<*>, | ||
/** | ||
* The duration for the transition, in milliseconds. | ||
* You may specify a single timeout for all transitions, or individually with an object. | ||
* | ||
* Set to 'auto' to automatically calculate transition time based on height. | ||
*/ | ||
timeout: TransitionDuration, | ||
}; | ||
|
||
class Paper extends React.Component<ProvidedProps & Props> { | ||
static defaultProps = { | ||
anchorOrigin: ({ | ||
vertical: 'top', | ||
horizontal: 'left', | ||
}: Origin), | ||
labelRowsPerPage: ('Rows per page:': Node), | ||
component: ('div': ElementType), | ||
component: 'div', | ||
elevation: 2, | ||
timeout: (duration.standard: TransitionDuration), | ||
}; | ||
|
||
render() { | ||
const { | ||
classes, | ||
component: ComponentProp, | ||
transition, | ||
...other | ||
} = this.props; | ||
|
||
return <ComponentProp className={classes.root} transition={transition} {...other} />; | ||
} | ||
} | ||
|
||
export default Paper; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: What is this doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to ElementType to avoid other flow errors and avoid typing all default props. Just one alternative. BTW We have since removed flow from our codebase.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for explaining.
Yeah in my company we also dropped flow, because it was too hard to keep up and we had to add lots of workarounds and rewrite code just to make flow happy