Skip to content

Commit bad531c

Browse files
committed
Minor Flow annotation tweaks
1 parent 464b273 commit bad531c

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

src/renderers/testing/ReactTestRendererFiber.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,31 @@ var emptyObject = require('emptyObject');
1919

2020
import type { TestRendererOptions } from 'ReactTestMount';
2121

22-
var CONTAINER_TYPE = 'CONTAINER';
23-
var INSTANCE_TYPE = 'INSTANCE';
24-
var TEXT_TYPE = 'TEXT';
25-
2622
type ReactTestRendererJSON = {|
27-
type: string,
28-
props: { [propName: string]: string },
29-
children: null | Array<string | ReactTestRendererJSON>,
30-
$$typeof?: any
23+
type : string,
24+
props : { [propName: string]: string },
25+
children : null | Array<string | ReactTestRendererJSON>,
26+
$$typeof ?: Symbol, // Optional because we add it with defineProperty().
3127
|};
3228

3329
type Container = {|
34-
children: Array<Instance | TextInstance>,
35-
createNodeMock: Function,
36-
$$typeof: typeof CONTAINER_TYPE,
30+
children : Array<Instance | TextInstance>,
31+
createNodeMock : Function,
32+
$$typeof : 'CONTAINER',
3733
|};
3834

3935
type Props = Object;
4036
type Instance = {|
41-
type: string,
42-
props: Object,
43-
children: Array<Instance | TextInstance>,
44-
rootContainerInstance: Container,
45-
$$typeof: typeof INSTANCE_TYPE,
37+
type : string,
38+
props : Object,
39+
children : Array<Instance | TextInstance>,
40+
rootContainerInstance : Container,
41+
$$typeof : 'INSTANCE',
4642
|};
4743

4844
type TextInstance = {|
49-
text: string,
50-
$$typeof: typeof TEXT_TYPE,
45+
text : string,
46+
$$typeof : 'TEXT',
5147
|};
5248

5349
var TestRenderer = ReactFiberReconciler({
@@ -79,7 +75,7 @@ var TestRenderer = ReactFiberReconciler({
7975
props,
8076
children: [],
8177
rootContainerInstance,
82-
$$typeof: INSTANCE_TYPE,
78+
$$typeof: 'INSTANCE',
8379
};
8480

8581
return inst;
@@ -150,7 +146,7 @@ var TestRenderer = ReactFiberReconciler({
150146
) : TextInstance {
151147
return {
152148
text,
153-
$$typeof: TEXT_TYPE,
149+
$$typeof: 'TEXT',
154150
};
155151
},
156152

@@ -197,12 +193,12 @@ var TestRenderer = ReactFiberReconciler({
197193

198194
getPublicInstance(ref) {
199195
switch (ref.$$typeof) {
200-
case CONTAINER_TYPE:
196+
case 'CONTAINER':
201197
return ref.createNodeMock(ref.children[0]);
202-
case INSTANCE_TYPE:
198+
case 'INSTANCE':
203199
const createNodeMock = ref.rootContainerInstance.createNodeMock;
204200
return createNodeMock(ref);
205-
case TEXT_TYPE:
201+
case 'TEXT':
206202
return ref.text;
207203
default:
208204
throw new Error('Attempted to getPublicInstance on an invalid ref.');
@@ -250,7 +246,7 @@ var ReactTestFiberRenderer = {
250246
var container = {
251247
children: [],
252248
createNodeMock,
253-
$$typeof: CONTAINER_TYPE,
249+
$$typeof: 'CONTAINER',
254250
};
255251
var root = TestRenderer.createContainer(container);
256252
TestRenderer.updateContainer(element, root, null, null);

0 commit comments

Comments
 (0)