Skip to content

Commit

Permalink
Add React.Suspense component and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Nov 28, 2018
1 parent 741ce2a commit 2fdcda5
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ declare module react {
declare export var ConcurrentMode: ({children: ?React$Node}) => React$Node; // 16.7+
declare export var StrictMode: ({children: ?React$Node}) => React$Node;

declare export var Suspense: React$ComponentType<{
children?: ?React$Node,
fallback: React$Node,
maxDuration?: number
}>; // 16.6+

declare export type ElementProps<C> = React$ElementProps<C>;
declare export type ElementConfig<C> = React$ElementConfig<C>;
declare export type ElementRef<C> = React$ElementRef<C>;
Expand Down Expand Up @@ -353,6 +359,7 @@ declare module react {
+Children: typeof Children,
+ConcurrentMode: typeof ConcurrentMode,
+StrictMode: typeof StrictMode,
+Suspense: typeof Suspense,
+useContext: typeof useContext,
+useState: typeof useState,
+useReducer: typeof useReducer,
Expand Down
10 changes: 10 additions & 0 deletions tests/getters_and_setters/getters_and_setters.exp
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,13 @@ References:
react.js:17:13
17| (<Example a="bad" />); // error: number ~> string
^^^^^ [1]
<<<<<<< HEAD
<BUILTINS>/react.js:404:36
404| number: React$PropType$Primitive<number>;
=======
<BUILTINS>/react.js:403:36
403| number: React$PropType$Primitive<number>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [2]


Expand All @@ -482,8 +487,13 @@ References:
react.js:18:20
18| (<Example a={0} c={0} />); // error: number ~> string
^ [1]
<<<<<<< HEAD
<BUILTINS>/react.js:406:36
406| string: React$PropType$Primitive<string>;
=======
<BUILTINS>/react.js:405:36
405| string: React$PropType$Primitive<string>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [2]


Expand Down
54 changes: 54 additions & 0 deletions tests/new_react/new_react.exp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ Cannot assign `this.props.x` to `_` because number [1] is incompatible with stri
^^^^^^^^^^^^

References:
<<<<<<< HEAD
<BUILTINS>/react.js:404:36
404| number: React$PropType$Primitive<number>;
=======
<BUILTINS>/react.js:403:36
403| number: React$PropType$Primitive<number>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [1]
classes.js:57:12
57| var _: string = this.props.x;
Expand Down Expand Up @@ -388,8 +393,13 @@ Cannot assign `this.props.z` to `qux` because:
^^^^^^^^^^^^

References:
<<<<<<< HEAD
<BUILTINS>/react.js:404:36
404| number: React$PropType$Primitive<number>;
=======
<BUILTINS>/react.js:403:36
403| number: React$PropType$Primitive<number>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [1]
new_react.js:19:18
19| var qux: string = this.props.z;
Expand All @@ -405,8 +415,13 @@ Cannot assign `this.props.x` to `w` because string [1] is incompatible with numb
^^^^^^^^^^^^

References:
<<<<<<< HEAD
<BUILTINS>/react.js:406:36
406| string: React$PropType$Primitive<string>;
=======
<BUILTINS>/react.js:405:36
405| string: React$PropType$Primitive<string>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [1]
new_react.js:20:15
20| var w:number = this.props.x;
Expand Down Expand Up @@ -439,8 +454,13 @@ References:
new_react.js:29:23
29| var element = <C x = {0}/>;
^ [1]
<<<<<<< HEAD
<BUILTINS>/react.js:406:36
406| string: React$PropType$Primitive<string>;
=======
<BUILTINS>/react.js:405:36
405| string: React$PropType$Primitive<string>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [2]


Expand Down Expand Up @@ -545,8 +565,13 @@ Cannot assign `this.props.x` to `a` because:
^^^^^^^^^^^^

References:
<<<<<<< HEAD
<BUILTINS>/react.js:406:36
406| string: React$PropType$Primitive<string>;
=======
<BUILTINS>/react.js:405:36
405| string: React$PropType$Primitive<string>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [1]
props.js:14:16
14| var a: number = this.props.x; // error
Expand Down Expand Up @@ -582,8 +607,13 @@ Cannot assign `this.props.z` to `c` because:
^^^^^^^^^^^^

References:
<<<<<<< HEAD
<BUILTINS>/react.js:404:36
404| number: React$PropType$Primitive<number>;
=======
<BUILTINS>/react.js:403:36
403| number: React$PropType$Primitive<number>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [1]
props.js:16:16
16| var c: string = this.props.z; // error
Expand All @@ -604,14 +634,24 @@ References:
props.js:20:29
20| var element = <TestProps x={false} y={false} z={false} />; // 3 errors
^^^^^ [1]
<<<<<<< HEAD
<BUILTINS>/react.js:406:36
406| string: React$PropType$Primitive<string>;
=======
<BUILTINS>/react.js:405:36
405| string: React$PropType$Primitive<string>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [2]
props.js:20:49
20| var element = <TestProps x={false} y={false} z={false} />; // 3 errors
^^^^^ [3]
<<<<<<< HEAD
<BUILTINS>/react.js:404:36
404| number: React$PropType$Primitive<number>;
=======
<BUILTINS>/react.js:403:36
403| number: React$PropType$Primitive<number>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [4]


Expand Down Expand Up @@ -668,8 +708,13 @@ References:
props2.js:9:41
9| getInitialState: function(): { bar: number } {
^^^^^^ [1]
<<<<<<< HEAD
<BUILTINS>/react.js:406:36
406| string: React$PropType$Primitive<string>;
=======
<BUILTINS>/react.js:405:36
405| string: React$PropType$Primitive<string>;
>>>>>>> Add React.Suspense component and tests
^^^^^^ [2]
props2.js:15:42
15| return <C {...this.state} foo = {0} />;
Expand Down Expand Up @@ -700,12 +745,21 @@ Cannot get `React.PropTypes.string.inRequired` because property `inRequired` is
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

References:
<<<<<<< HEAD
<BUILTINS>/react.js:380:39
v
380| type ReactPropsChainableTypeChecker = {
381| isRequired: ReactPropsCheckType;
382| (props: any, propName: string, componentName: string, href?: string): ?Error;
383| };
=======
<BUILTINS>/react.js:379:39
v
379| type ReactPropsChainableTypeChecker = {
380| isRequired: ReactPropsCheckType;
381| (props: any, propName: string, componentName: string, href?: string): ?Error;
382| };
>>>>>>> Add React.Suspense component and tests
^ [1]


Expand Down
Loading

0 comments on commit 2fdcda5

Please sign in to comment.