-
Notifications
You must be signed in to change notification settings - Fork 24.8k
[FlowCleanup] InspectorPanel -> Delete PropTypes #21392
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
Changes from 6 commits
d818626
59c68f3
758c13a
d234739
15406ff
a8dd2fd
db5d2f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,43 @@ const ElementProperties = require('ElementProperties'); | |
const NetworkOverlay = require('NetworkOverlay'); | ||
const PerformanceOverlay = require('PerformanceOverlay'); | ||
const React = require('React'); | ||
const PropTypes = require('prop-types'); | ||
const ScrollView = require('ScrollView'); | ||
const StyleSheet = require('StyleSheet'); | ||
const Text = require('Text'); | ||
const TouchableHighlight = require('TouchableHighlight'); | ||
const View = require('View'); | ||
|
||
class InspectorPanel extends React.Component<$FlowFixMeProps> { | ||
import type {ViewStyleProp} from 'StyleSheet'; | ||
|
||
type Props = $ReadOnly<{| | ||
devtoolsIsOpen?: ?boolean, | ||
inspecting?: ?boolean, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Circle CI errors indicate that we need to strict type it rather than
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the following work? if (value === true) {
// stuff
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. But these props can be either boolean or undefined. I don't know how to write for both?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... There's only one use of
Lets make the |
||
setInspecting?: ?(val: boolean) => void, | ||
perfing?: ?boolean, | ||
setPerfing?: ?(val: boolean) => void, | ||
touchTargeting?: ?boolean, | ||
setTouchTargeting?: ?(val: boolean) => void, | ||
networking?: ?boolean, | ||
setNetworking?: ?(val: boolean) => void, | ||
hierarchy?: any, | ||
selection?: ?number, | ||
setSelection?: number => mixed, | ||
inspected?: ?{ | ||
style?: ?ViewStyleProp, | ||
frame?: ?{ | ||
top?: ?number, | ||
left?: ?number, | ||
width?: ?number, | ||
height: ?number, | ||
}, | ||
source?: ?{ | ||
fileName?: string, | ||
lineNumber?: number, | ||
}, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should be more strict and use exact object types here, so: inspected?: ?{|
style?: ?ViewStyleProp,
frame?: ?{|
top?: ?number,
left?: ?number,
width?: ?number,
height: ?number,
|},
source?: ?{|
fileName?: string,
lineNumber?: number,
|},
|}, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool. Also, I found these types from other components. So should we export these types on those components and reference them here? There are many components in Inspector which needs to be converted to flow types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that sounds like a great idea! I can see there being an Would you like to tackle this in another PR? For now, we can just copy-paste the frame type here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. I'll finish up with this today and work on the Inspector folder next week. |
||
|}>; | ||
|
||
class InspectorPanel extends React.Component<Props> { | ||
renderWaiting() { | ||
if (this.props.inspecting) { | ||
return ( | ||
|
@@ -57,22 +86,22 @@ class InspectorPanel extends React.Component<$FlowFixMeProps> { | |
<View style={styles.container}> | ||
{!this.props.devtoolsIsOpen && contents} | ||
<View style={styles.buttonRow}> | ||
<Button | ||
<InspectorPanelButton | ||
title={'Inspect'} | ||
pressed={this.props.inspecting} | ||
onClick={this.props.setInspecting} | ||
/> | ||
<Button | ||
<InspectorPanelButton | ||
title={'Perf'} | ||
pressed={this.props.perfing} | ||
onClick={this.props.setPerfing} | ||
/> | ||
<Button | ||
<InspectorPanelButton | ||
title={'Network'} | ||
pressed={this.props.networking} | ||
onClick={this.props.setNetworking} | ||
/> | ||
<Button | ||
<InspectorPanelButton | ||
title={'Touchables'} | ||
pressed={this.props.touchTargeting} | ||
onClick={this.props.setTouchTargeting} | ||
|
@@ -83,20 +112,13 @@ class InspectorPanel extends React.Component<$FlowFixMeProps> { | |
} | ||
} | ||
|
||
InspectorPanel.propTypes = { | ||
devtoolsIsOpen: PropTypes.bool, | ||
inspecting: PropTypes.bool, | ||
setInspecting: PropTypes.func, | ||
inspected: PropTypes.object, | ||
perfing: PropTypes.bool, | ||
setPerfing: PropTypes.func, | ||
touchTargeting: PropTypes.bool, | ||
setTouchTargeting: PropTypes.func, | ||
networking: PropTypes.bool, | ||
setNetworking: PropTypes.func, | ||
}; | ||
type InspectorPanelButtonProps = $ReadOnly<{| | ||
onClick?: ?Function, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RSNara I need a similar params/return type here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. This should also take the same signature:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that I think about it more, a lot of these types are unnecessarily optional. For example, I think |
||
pressed?: ?boolean, | ||
title?: ?string, | ||
|}>; | ||
|
||
class Button extends React.Component<$FlowFixMeProps> { | ||
class InspectorPanelButton extends React.Component<InspectorPanelButtonProps> { | ||
render() { | ||
return ( | ||
<TouchableHighlight | ||
|
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.
Unclear type. Using
any
,Object
,Function
,$Subtype<...>
, or$Supertype<...>
types is not safe! (unclear-type
)