Skip to content

Commit eed4db4

Browse files
committed
more updates for flow configs exposed by making objects with indexer exact
1 parent 7fbb058 commit eed4db4

File tree

6 files changed

+15
-2
lines changed

6 files changed

+15
-2
lines changed

packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ export {createResponse, close};
2424

2525
export function resolveRow(response: Response, chunk: RowEncoding): void {
2626
if (chunk[0] === 'J') {
27+
// $FlowFixMe unable to refine on array indices
2728
resolveModel(response, chunk[1], chunk[2]);
2829
} else if (chunk[0] === 'M') {
30+
// $FlowFixMe unable to refine on array indices
2931
resolveModule(response, chunk[1], chunk[2]);
3032
} else if (chunk[0] === 'S') {
3133
// $FlowFixMe: Flow doesn't support disjoint unions on tuples.

packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type JSONValue =
1515
| boolean
1616
| null
1717
| {|+[key: string]: JSONValue|}
18-
| Array<JSONValue>;
18+
| $ReadOnlyArray<JSONValue>;
1919

2020
export type RowEncoding =
2121
| ['J', number, JSONValue]

packages/react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export function processModelChunk(
115115
id: number,
116116
model: ReactModel,
117117
): Chunk {
118+
// $FlowFixMe no good way to define an empty exact object
118119
const json = convertModelToJSON(request, {}, '', model);
119120
return ['J', id, json];
120121
}
@@ -161,13 +162,15 @@ export function flushBuffered(destination: Destination) {}
161162
export function beginWriting(destination: Destination) {}
162163

163164
export function writeChunk(destination: Destination, chunk: Chunk): void {
165+
// $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type.
164166
emitRow(destination, chunk);
165167
}
166168

167169
export function writeChunkAndReturn(
168170
destination: Destination,
169171
chunk: Chunk,
170172
): boolean {
173+
// $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type.
171174
emitRow(destination, chunk);
172175
return true;
173176
}

packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ export {createResponse, close};
2424

2525
export function resolveRow(response: Response, chunk: RowEncoding): void {
2626
if (chunk[0] === 'J') {
27+
// $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type.
2728
resolveModel(response, chunk[1], chunk[2]);
2829
} else if (chunk[0] === 'M') {
30+
// $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type.
2931
resolveModule(response, chunk[1], chunk[2]);
3032
} else if (chunk[0] === 'S') {
3133
// $FlowFixMe: Flow doesn't support disjoint unions on tuples.

packages/react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function convertModelToJSON(
8888
}
8989
return jsonArray;
9090
} else {
91+
// $FlowFixMe no good way to define an empty exact object
9192
const jsonObj: {|[key: string]: JSONValue|} = {};
9293
for (const nextKey in json) {
9394
if (hasOwnProperty.call(json, nextKey)) {
@@ -110,6 +111,7 @@ export function processModelChunk(
110111
id: number,
111112
model: ReactModel,
112113
): Chunk {
114+
// $FlowFixMe no good way to define an empty exact object
113115
const json = convertModelToJSON(request, {}, '', model);
114116
return ['J', id, json];
115117
}
@@ -156,13 +158,15 @@ export function flushBuffered(destination: Destination) {}
156158
export function beginWriting(destination: Destination) {}
157159

158160
export function writeChunk(destination: Destination, chunk: Chunk): void {
161+
// $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type.
159162
emitRow(destination, chunk);
160163
}
161164

162165
export function writeChunkAndReturn(
163166
destination: Destination,
164167
chunk: Chunk,
165168
): boolean {
169+
// $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type.
166170
emitRow(destination, chunk);
167171
return true;
168172
}

packages/react-server/src/ReactFlightServer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export type ReactModel =
9191
| Iterable<ReactModel>
9292
| ReactModelObject;
9393

94-
type ReactModelObject = {+[key: string]: ReactModel, ...};
94+
type ReactModelObject = {|+[key: string]: ReactModel|};
9595

9696
const PENDING = 0;
9797
const COMPLETED = 1;
@@ -272,6 +272,7 @@ function attemptResolveElement(
272272
);
273273
}
274274
}
275+
// $FlowFixMe issue discovered when updating Flow
275276
return [
276277
REACT_ELEMENT_TYPE,
277278
type,
@@ -698,6 +699,7 @@ export function resolveModelToJSON(
698699
}
699700
}
700701

702+
// $FlowFixMe
701703
return value;
702704
}
703705

0 commit comments

Comments
 (0)