Skip to content

Commit 6deaffb

Browse files
committed
Updated react-error-overlay to latest Flow (0.54.0)
1 parent e8b58ed commit 6deaffb

File tree

13 files changed

+92
-28
lines changed

13 files changed

+92
-28
lines changed

packages/react-error-overlay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"eslint-plugin-import": "2.7.0",
5252
"eslint-plugin-jsx-a11y": "5.1.1",
5353
"eslint-plugin-react": "7.1.0",
54-
"flow-bin": "0.52.0",
54+
"flow-bin": "^0.54.0",
5555
"jest": "20.0.4",
5656
"jest-fetch-mock": "1.2.1"
5757
},

packages/react-error-overlay/src/__tests__/__snapshots__/unmapper.js.snap

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,44 @@ Array [
4646
],
4747
"_scriptCode": Array [
4848
ScriptLine {
49-
"content": " },",
49+
"content": " },
50+
",
5051
"highlight": false,
5152
"lineNumber": 41463,
5253
},
5354
ScriptLine {
54-
"content": " [1, 2].map(function (v) {",
55+
"content": " [1, 2].map(function (v) {
56+
",
5557
"highlight": false,
5658
"lineNumber": 41464,
5759
},
5860
ScriptLine {
59-
"content": " return _react2.default.createElement(",
61+
"content": " return _react2.default.createElement(
62+
",
6063
"highlight": false,
6164
"lineNumber": 41465,
6265
},
6366
ScriptLine {
64-
"content": " 'div',",
67+
"content": " 'div',
68+
",
6569
"highlight": true,
6670
"lineNumber": 41466,
6771
},
6872
ScriptLine {
69-
"content": " {",
73+
"content": " {
74+
",
7075
"highlight": false,
7176
"lineNumber": 41467,
7277
},
7378
ScriptLine {
74-
"content": " __source: {",
79+
"content": " __source: {
80+
",
7581
"highlight": false,
7682
"lineNumber": 41468,
7783
},
7884
ScriptLine {
79-
"content": " fileName: _jsxFileName,",
85+
"content": " fileName: _jsxFileName,
86+
",
8087
"highlight": false,
8188
"lineNumber": 41469,
8289
},

packages/react-error-overlay/src/components/Collapsible.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/* @flow */
1111
import React, { Component } from 'react';
12+
import type { Element } from 'react';
1213
import { black } from '../styles';
1314

1415
const _collapsibleStyle = {
@@ -35,7 +36,15 @@ const collapsibleExpandedStyle = {
3536
marginBottom: '0.6em',
3637
};
3738

38-
class Collapsible extends Component {
39+
type Props = {|
40+
children: Element<any>[]
41+
|};
42+
43+
type State = {|
44+
collapsed: boolean
45+
|};
46+
47+
class Collapsible extends Component<Props, State> {
3948
state = {
4049
collapsed: true,
4150
};

packages/react-error-overlay/src/components/ErrorOverlay.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/* @flow */
1111
import React, { Component } from 'react';
12+
import type { Node } from 'react';
1213
import { black } from '../styles';
1314

1415
const overlayStyle = {
@@ -31,10 +32,19 @@ const overlayStyle = {
3132
color: black,
3233
};
3334

34-
class ErrorOverlay extends Component {
35+
type Props = {|
36+
children: Node,
37+
shortcutHandler?: (eventKey: string) => void
38+
|};
39+
40+
type State = {|
41+
collapsed: boolean
42+
|};
43+
44+
class ErrorOverlay extends Component<Props, State> {
3545
iframeWindow: window = null;
3646

37-
getIframeWindow = (element: HTMLDivElement) => {
47+
getIframeWindow = (element: ?HTMLDivElement) => {
3848
if (element) {
3949
const document = element.ownerDocument;
4050
this.iframeWindow = document.defaultView;

packages/react-error-overlay/src/containers/CompileErrorContainer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import Header from '../components/Header';
1515
import CodeBlock from '../components/CodeBlock';
1616
import generateAnsiHTML from '../utils/generateAnsiHTML';
1717

18-
class CompileErrorContainer extends PureComponent {
18+
type Props = {|
19+
error: string
20+
|};
21+
22+
class CompileErrorContainer extends PureComponent<Props, void> {
1923
render() {
2024
const { error } = this.props;
2125
return (

packages/react-error-overlay/src/containers/RuntimeError.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ function RuntimeError({ errorRecord, launchEditorEndpoint }: Props) {
6565
);
6666
}
6767

68+
export type { ErrorRecord };
6869
export default RuntimeError;

packages/react-error-overlay/src/containers/RuntimeErrorContainer.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@ import CloseButton from '../components/CloseButton';
1414
import NavigationBar from '../components/NavigationBar';
1515
import RuntimeError from './RuntimeError';
1616
import Footer from '../components/Footer';
17+
import type { ErrorRecord } from './RuntimeError';
1718

18-
class RuntimeErrorContainer extends PureComponent {
19+
type Props = {|
20+
errorRecords: ErrorRecord[],
21+
close: () => void,
22+
launchEditorEndpoint: ?string
23+
|};
24+
25+
type State = {|
26+
currentIndex: number
27+
|};
28+
29+
class RuntimeErrorContainer extends PureComponent<Props, State> {
1930
state = {
2031
currentIndex: 0,
2132
};

packages/react-error-overlay/src/containers/StackFrame.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import React, { Component } from 'react';
1212
import CodeBlock from './StackFrameCodeBlock';
1313
import { getPrettyURL } from '../utils/getPrettyURL';
1414
import { darkGray } from '../styles';
15+
import type { StackFrame as StackFrameType } from '../utils/stack-frame';
1516

1617
const linkStyle = {
1718
fontSize: '0.9em',
@@ -43,7 +44,19 @@ const toggleStyle = {
4344
lineHeight: '1.5',
4445
};
4546

46-
class StackFrame extends Component {
47+
type Props = {|
48+
frame: StackFrameType,
49+
launchEditorEndpoint: ?string,
50+
contextSize: number,
51+
critical: boolean,
52+
showCode: boolean
53+
|};
54+
55+
type State = {|
56+
compiled: boolean
57+
|};
58+
59+
class StackFrame extends Component<Props, State> {
4760
state = {
4861
compiled: false,
4962
};
@@ -74,7 +87,7 @@ class StackFrame extends Component {
7487
}
7588

7689
openInEditor = () => {
77-
if (!this.canOpenInEditor()) {
90+
if (!this.props.launchEditorEndpoint) {
7891
return;
7992
}
8093
const {
@@ -90,7 +103,7 @@ class StackFrame extends Component {
90103
).then(() => {}, () => {});
91104
};
92105

93-
onKeyDown = (e: SyntheticKeyboardEvent) => {
106+
onKeyDown = (e: SyntheticKeyboardEvent<>) => {
94107
if (e.key === 'Enter') {
95108
this.openInEditor();
96109
}

packages/react-error-overlay/src/containers/StackFrameCodeBlock.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ import codeFrame from 'babel-code-frame';
2121
type StackFrameCodeBlockPropsType = {|
2222
lines: ScriptLine[],
2323
lineNum: number,
24-
columnNum: number,
24+
columnNum: ?number,
2525
contextSize: number,
2626
main: boolean,
2727
|};
2828

29-
function StackFrameCodeBlock(props: StackFrameCodeBlockPropsType) {
29+
// Exact type workaround for spread operator.
30+
// See: https://github.com/facebook/flow/issues/2405
31+
type Exact<T> = $Shape<T>;
32+
33+
function StackFrameCodeBlock(props: Exact<StackFrameCodeBlockPropsType>) {
3034
const { lines, lineNum, columnNum, contextSize, main } = props;
3135
const sourceCode = [];
3236
let whiteSpace = Infinity;

packages/react-error-overlay/src/containers/StackTrace.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import StackFrame from './StackFrame';
1313
import Collapsible from '../components/Collapsible';
1414
import { isInternalFile } from '../utils/isInternalFile';
1515
import { isBultinErrorName } from '../utils/isBultinErrorName';
16+
import type { StackFrame as StackFrameType } from '../utils/stack-frame';
1617

1718
const traceStyle = {
1819
fontSize: '1em',
@@ -21,7 +22,14 @@ const traceStyle = {
2122
overflow: 'auto',
2223
};
2324

24-
class StackTrace extends Component {
25+
type Props = {|
26+
stackFrames: StackFrameType[],
27+
errorName: string,
28+
contextSize: number,
29+
launchEditorEndpoint: ?string,
30+
|};
31+
32+
class StackTrace extends Component<Props> {
2533
renderFrames() {
2634
const {
2735
stackFrames,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy