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

Replace $FlowFixMe in BoxInspector #48594

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions packages/react-native/Libraries/Inspector/BorderBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,26 @@

'use strict';

import type {ViewStyleProp} from '../StyleSheet/StyleSheet';

import React from 'react';

const View = require('../Components/View/View');
const React = require('react');

class BorderBox extends React.Component<$FlowFixMeProps> {
render(): $FlowFixMe | React.Node {
type Props = $ReadOnly<{|
children: React.Node,
box?: ?$ReadOnly<{
top: number,
right: number,
bottom: number,
left: number,
...
}>,
style?: ViewStyleProp,
|}>;

class BorderBox extends React.Component<Props> {
render(): React.Node {
const box = this.props.box;
if (!box) {
return this.props.children;
Expand Down
33 changes: 27 additions & 6 deletions packages/react-native/Libraries/Inspector/BoxInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@

'use strict';

import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
import type {InspectedElementFrame} from './Inspector';

import React from 'react';

const View = require('../Components/View/View');
const StyleSheet = require('../StyleSheet/StyleSheet');
const Text = require('../Text/Text');
const resolveBoxStyle = require('./resolveBoxStyle');
const React = require('react');

const blank = {
top: 0,
Expand All @@ -23,7 +27,12 @@ const blank = {
bottom: 0,
};

class BoxInspector extends React.Component<$FlowFixMeProps> {
type BoxInspectorProps = $ReadOnly<{
style: ViewStyleProp,
frame?: ?InspectedElementFrame,
}>;

class BoxInspector extends React.Component<BoxInspectorProps> {
render(): React.Node {
const frame = this.props.frame;
const style = this.props.style;
Expand All @@ -34,11 +43,11 @@ class BoxInspector extends React.Component<$FlowFixMeProps> {
<BoxContainer title="padding" box={padding}>
<View>
<Text style={styles.innerText}>
({(frame.left || 0).toFixed(1)}, {(frame.top || 0).toFixed(1)})
({(frame?.left || 0).toFixed(1)}, {(frame?.top || 0).toFixed(1)})
</Text>
<Text style={styles.innerText}>
{(frame.width || 0).toFixed(1)} &times;{' '}
{(frame.height || 0).toFixed(1)}
{(frame?.width || 0).toFixed(1)} &times;{' '}
{(frame?.height || 0).toFixed(1)}
</Text>
</View>
</BoxContainer>
Expand All @@ -47,7 +56,19 @@ class BoxInspector extends React.Component<$FlowFixMeProps> {
}
}

class BoxContainer extends React.Component<$FlowFixMeProps> {
type BoxContainerProps = $ReadOnly<{
title: string,
box: $ReadOnly<{
top: number,
right: number,
bottom: number,
left: number,
}>,
titleStyle?: ViewStyleProp,
children: React.Node,
}>;

class BoxContainer extends React.Component<BoxContainerProps> {
render(): React.Node {
const box = this.props.box;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5150,26 +5150,42 @@ declare module.exports: resolveAssetSource;
`;

exports[`public API should not change unintentionally Libraries/Inspector/BorderBox.js 1`] = `
"declare const React: $FlowFixMe;
declare class BorderBox extends React.Component<$FlowFixMeProps> {
render(): $FlowFixMe | React.Node;
"type Props = $ReadOnly<{|
children: React.Node,
box?: ?$ReadOnly<{
top: number,
right: number,
bottom: number,
left: number,
...
}>,
style?: ViewStyleProp,
|}>;
declare class BorderBox extends React.Component<Props> {
render(): React.Node;
}
declare module.exports: BorderBox;
"
`;

exports[`public API should not change unintentionally Libraries/Inspector/BoxInspector.js 1`] = `
"declare const React: $FlowFixMe;
declare class BoxInspector extends React.Component<$FlowFixMeProps> {
"type BoxInspectorProps = $ReadOnly<{
style: ViewStyleProp,
frame?: ?InspectedElementFrame,
}>;
declare class BoxInspector extends React.Component<BoxInspectorProps> {
render(): React.Node;
}
declare module.exports: BoxInspector;
"
`;

exports[`public API should not change unintentionally Libraries/Inspector/ElementBox.js 1`] = `
"declare const React: $FlowFixMe;
declare class ElementBox extends React.Component<$FlowFixMeProps> {
"type Props = $ReadOnly<{
style?: ViewStyleProp,
frame: InspectedElementFrame,
}>;
declare class ElementBox extends React.Component<Props> {
render(): React.Node;
}
declare module.exports: ElementBox;
Expand Down
Loading