2
2
* Copyright (c) 2013-present, Facebook, Inc.
3
3
*
4
4
* @emails react-core
5
+ * @flow
5
6
*/
6
7
7
8
'use strict' ;
8
9
9
10
import React , { Component } from 'react' ;
10
- import PropTypes from 'prop-types' ;
11
11
12
- function replaceArgs ( msg , argList ) {
12
+ function replaceArgs ( msg : string , argList : Array < any > ) : string {
13
13
let argIdx = 0 ;
14
14
return msg . replace ( / % s / g, function ( ) {
15
15
const arg = argList [ argIdx ++ ] ;
16
16
return arg === undefined ? '[missing argument]' : arg ;
17
17
} ) ;
18
18
}
19
19
20
- function urlify ( str ) {
20
+ function urlify ( str : string ) : Array < any > {
21
21
const urlRegex = / ( h t t p s : \/ \/ f b \. m e \/ [ a - z \- ] + ) / g;
22
22
23
23
const segments = str . split ( urlRegex ) ;
24
24
25
25
for ( let i = 0 ; i < segments . length ; i ++ ) {
26
26
if ( i % 2 === 1 ) {
27
27
segments [ i ] = (
28
+ // $FlowFixMe: We need to properly trace this error: React element 'a' inconsistent use of library definitions
28
29
< a key = { i } target = "_blank" rel = "noopener" href = { segments [ i ] } >
29
30
{ segments [ i ] }
30
31
</ a >
@@ -36,7 +37,7 @@ function urlify(str) {
36
37
}
37
38
38
39
// ?invariant=123& args [ ] = foo & args [ ] = bar
39
- function parseQueryString ( location ) {
40
+ function parseQueryString ( location : Location ) : null | Array < any > {
40
41
const rawQueryString = location . search . substring ( 1 ) ;
41
42
if ( ! rawQueryString ) {
42
43
return null ;
@@ -58,7 +59,12 @@ function parseQueryString(location) {
58
59
return [code, args];
59
60
}
60
61
61
- function ErrorResult ( props ) {
62
+ type ErrorResultProps = {
63
+ code : mixed ,
64
+ msg : string ,
65
+ } ;
66
+
67
+ function ErrorResult(props: ErrorResultProps) {
62
68
const code = props . code ;
63
69
const errorMsg = props . msg ;
64
70
@@ -79,8 +85,18 @@ function ErrorResult(props) {
79
85
) ;
80
86
}
81
87
82
- class ErrorDecoder extends Component {
83
- constructor ( ...args ) {
88
+ type ErrorDecoderProps = {
89
+ errorCodesString : string ,
90
+ location : Location ,
91
+ } ;
92
+
93
+ type State = {
94
+ code : mixed ,
95
+ errorMsg : string ,
96
+ } ;
97
+
98
+ class ErrorDecoder extends Component < ErrorDecoderProps , State > {
99
+ constructor ( ...args : Array < any > ) {
84
100
super ( ...args ) ;
85
101
86
102
this . state = {
@@ -109,9 +125,4 @@ class ErrorDecoder extends Component {
109
125
}
110
126
}
111
127
112
- ErrorDecoder . propTypes = {
113
- errorCodesString : PropTypes . string . isRequired ,
114
- location : PropTypes . object . isRequired ,
115
- } ;
116
-
117
128
export default ErrorDecoder ;
0 commit comments