Skip to content

Commit 47daa3b

Browse files
committed
[flow] Upgrade from 0.280 -> 0.281
Major changes in Flow 0.281: - $FlowFixMe comments now require explicit error codes (e.g., $FlowFixMe[incompatible-type]) - Changed all bare $FlowFixMe to include appropriate error codes - Changed $FlowIgnore to $FlowFixMe where needed - Fixed stream types to have cancel() return Promise<void> instead of void - Added pseudoElement property to KeyframeEffect type - Added suppressions for Proxy handler variance issues - Fixed various type errors across the codebase
1 parent b8d6b17 commit 47daa3b

35 files changed

+148
-108
lines changed

flow-typed/environments/streams.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare class ReadableStreamReader {
4242

4343
closed: boolean;
4444

45-
cancel(reason: string): void;
45+
cancel(reason: mixed): Promise<void>;
4646
read(): Promise<{
4747
value: ?any,
4848
done: boolean,
@@ -57,7 +57,7 @@ declare interface UnderlyingSource {
5757

5858
start?: (controller: ReadableStreamController) => ?Promise<void>;
5959
pull?: (controller: ReadableStreamController) => ?Promise<void>;
60-
cancel?: (reason: string) => ?Promise<void>;
60+
cancel?: (reason: mixed) => ?Promise<void>;
6161
}
6262

6363
declare class TransformStream {
@@ -91,7 +91,7 @@ declare class ReadableStream {
9191

9292
locked: boolean;
9393

94-
cancel(reason: string): void;
94+
cancel(reason: mixed): Promise<void>;
9595
getReader(): ReadableStreamReader;
9696
pipeThrough(transform: PipeThroughTransformStream, options: ?any): void;
9797
pipeTo(dest: WritableStream, options: ?PipeToOptions): Promise<void>;
@@ -106,7 +106,7 @@ declare interface UnderlyingSink {
106106
autoAllocateChunkSize?: number;
107107
type?: string;
108108

109-
abort?: (reason: string) => ?Promise<void>;
109+
abort?: (reason: mixed) => ?Promise<void>;
110110
close?: (controller: WritableStreamController) => ?Promise<void>;
111111
start?: (controller: WritableStreamController) => ?Promise<void>;
112112
write?: (chunk: any, controller: WritableStreamController) => ?Promise<void>;

flow-typed/environments/web-animations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ declare class KeyframeEffect extends AnimationEffect {
182182
constructor(source: KeyframeEffect): void;
183183

184184
target: Element | null;
185+
pseudoElement: string | null;
185186
composite: CompositeOperation;
186187
// This is actually web-animations-2
187188
iterationComposite: IterationCompositeOperation;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
7676
"fbjs-scripts": "^3.0.1",
7777
"filesize": "^6.0.1",
78-
"flow-bin": "^0.280.0",
79-
"flow-remove-types": "^2.280.0",
78+
"flow-bin": "^0.281.0",
79+
"flow-remove-types": "^2.281.0",
8080
"flow-typed": "^4.1.1",
8181
"glob": "^7.1.6",
8282
"glob-stream": "^6.1.0",

packages/react-client/src/ReactClientConsoleConfigBrowser.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function bindToConsole(
3535
case 'groupEnd':
3636
case 'table': {
3737
// These methods cannot be colorized because they don't take a formatting string.
38-
// $FlowFixMe
38+
// $FlowFixMe[incompatible-type]
3939
return bind.apply(console[methodName], [console].concat(args)); // eslint-disable-line react-internal/no-production-logging
4040
}
4141
case 'assert': {
@@ -68,6 +68,7 @@ export function bindToConsole(
6868
// The "this" binding in the "bind";
6969
newArgs.unshift(console);
7070

71-
// $FlowFixMe
71+
// $FlowFixMe[incompatible-type]
72+
// $FlowFixMe[invalid-computed-prop]
7273
return bind.apply(console[methodName], newArgs); // eslint-disable-line react-internal/no-production-logging
7374
}

packages/react-client/src/ReactClientConsoleConfigPlain.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function bindToConsole(
2525
case 'groupEnd':
2626
case 'table': {
2727
// These methods cannot be colorized because they don't take a formatting string.
28-
// $FlowFixMe
28+
// $FlowFixMe[incompatible-type]
2929
return bind.apply(console[methodName], [console].concat(args)); // eslint-disable-line react-internal/no-production-logging
3030
}
3131
case 'assert': {
@@ -49,6 +49,7 @@ export function bindToConsole(
4949
// The "this" binding in the "bind";
5050
newArgs.unshift(console);
5151

52-
// $FlowFixMe
52+
// $FlowFixMe[incompatible-type]
53+
// $FlowFixMe[invalid-computed-prop]
5354
return bind.apply(console[methodName], newArgs); // eslint-disable-line react-internal/no-production-logging
5455
}

packages/react-client/src/ReactClientConsoleConfigServer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function bindToConsole(
3636
case 'groupEnd':
3737
case 'table': {
3838
// These methods cannot be colorized because they don't take a formatting string.
39-
// $FlowFixMe
39+
// $FlowFixMe[incompatible-type]
4040
return bind.apply(console[methodName], [console].concat(args)); // eslint-disable-line react-internal/no-production-logging
4141
}
4242
case 'assert': {
@@ -69,6 +69,7 @@ export function bindToConsole(
6969
// The "this" binding in the "bind";
7070
newArgs.unshift(console);
7171

72-
// $FlowFixMe
72+
// $FlowFixMe[incompatible-type]
73+
// $FlowFixMe[invalid-computed-prop]
7374
return bind.apply(console[methodName], newArgs); // eslint-disable-line react-internal/no-production-logging
7475
}

packages/react-client/src/ReactFlightClient.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ ReactPromise.prototype.then = function <T>(
283283
const rejectCallback = reject;
284284
const wrapperPromise: Promise<T> = new Promise((res, rej) => {
285285
resolve = value => {
286-
// $FlowFixMe
286+
// $FlowFixMe[prop-missing]
287287
wrapperPromise._debugInfo = this._debugInfo;
288288
res(value);
289289
};
290290
reject = reason => {
291-
// $FlowFixMe
291+
// $FlowFixMe[prop-missing]
292292
wrapperPromise._debugInfo = this._debugInfo;
293293
rej(reason);
294294
};
@@ -3922,7 +3922,7 @@ function initializeDebugInfo(
39223922
}
39233923
if (debugInfo.owner == null && response._debugRootOwner != null) {
39243924
const componentInfoOrAsyncInfo: ReactComponentInfo | ReactAsyncInfo =
3925-
// $FlowFixMe: By narrowing `owner` to `null`, we narrowed `debugInfo` to `ReactComponentInfo`
3925+
// $FlowFixMe[incompatible-type]: By narrowing `owner` to `null`, we narrowed `debugInfo` to `ReactComponentInfo`
39263926
debugInfo;
39273927
// $FlowFixMe[cannot-write]
39283928
componentInfoOrAsyncInfo.owner = response._debugRootOwner;
@@ -4268,7 +4268,7 @@ function logComponentInfo(
42684268
childrenEndTime: number,
42694269
isLastComponent: boolean,
42704270
): void {
4271-
// $FlowFixMe: Refined.
4271+
// $FlowFixMe[incompatible-use]: Refined.
42724272
if (
42734273
isLastComponent &&
42744274
root.status === ERRORED &&
@@ -4447,7 +4447,7 @@ function flushComponentPerformance(
44474447
if (componentEndTime > childrenEndTime) {
44484448
childrenEndTime = componentEndTime;
44494449
}
4450-
// $FlowFixMe: Refined.
4450+
// $FlowFixMe[incompatible-type]: Refined.
44514451
const componentInfo: ReactComponentInfo = candidateInfo;
44524452
logComponentInfo(
44534453
response,
@@ -4471,7 +4471,7 @@ function flushComponentPerformance(
44714471
if (endTime > childrenEndTime) {
44724472
childrenEndTime = endTime;
44734473
}
4474-
// $FlowFixMe: Refined.
4474+
// $FlowFixMe[incompatible-type]: Refined.
44754475
const asyncInfo: ReactAsyncInfo = candidateInfo;
44764476
const env = response._rootEnvironmentName;
44774477
const promise = asyncInfo.awaited.value;
@@ -4534,7 +4534,7 @@ function flushComponentPerformance(
45344534
if (componentEndTime > childrenEndTime) {
45354535
childrenEndTime = componentEndTime;
45364536
}
4537-
// $FlowFixMe: Refined.
4537+
// $FlowFixMe[incompatible-type]: Refined.
45384538
const componentInfo: ReactComponentInfo = candidateInfo;
45394539
const env = response._rootEnvironmentName;
45404540
logComponentAborted(

packages/react-client/src/ReactFlightClientStreamConfigNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function createStringDecoder(): StringDecoder {
1515
return new TextDecoder();
1616
}
1717

18-
const decoderOptions = {stream: true};
18+
const decoderOptions: {stream?: boolean, ...} = {stream: true};
1919

2020
export function readPartialStringChunk(
2121
decoder: StringDecoder,

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,11 +1712,11 @@ function moveOutOfViewport(
17121712
// while still letting it paint its "old" state to a snapshot.
17131713
const transform = getComputedTransform(originalStyle);
17141714
// Clear the long form properties.
1715-
// $FlowFixMe
1715+
// $FlowFixMe[prop-missing]
17161716
element.style.translate = 'none';
1717-
// $FlowFixMe
1717+
// $FlowFixMe[prop-missing]
17181718
element.style.scale = 'none';
1719-
// $FlowFixMe
1719+
// $FlowFixMe[prop-missing]
17201720
element.style.rotate = 'none';
17211721
// Apply a translate to move it way out of the viewport. This is applied first
17221722
// so that it is in the coordinate space of the parent and not after applying
@@ -1799,7 +1799,7 @@ export function cloneRootViewTransitionContainer(
17991799
if (getComputedStyle(positionedAncestor).position !== 'static') {
18001800
break;
18011801
}
1802-
// $FlowFixMe: This is refined.
1802+
// $FlowFixMe[incompatible-type]: This is refined.
18031803
positionedAncestor = positionedAncestor.parentNode;
18041804
}
18051805

@@ -2005,7 +2005,6 @@ function cancelAllViewTransitionAnimations(scope: Element) {
20052005
for (let i = 0; i < animations.length; i++) {
20062006
const anim = animations[i];
20072007
const effect: KeyframeEffect = (anim.effect: any);
2008-
// $FlowFixMe
20092008
const pseudo: ?string = effect.pseudoElement;
20102009
if (
20112010
pseudo != null &&
@@ -2219,7 +2218,6 @@ export function startViewTransition(
22192218
for (let i = 0; i < animations.length; i++) {
22202219
const animation = animations[i];
22212220
const effect: KeyframeEffect = (animation.effect: any);
2222-
// $FlowFixMe
22232221
const pseudoElement: ?string = effect.pseudoElement;
22242222
if (
22252223
pseudoElement != null &&
@@ -2260,13 +2258,13 @@ export function startViewTransition(
22602258
height !== undefined
22612259
) {
22622260
// Replace the keyframes with ones that don't animate the width/height.
2263-
// $FlowFixMe
2261+
// $FlowFixMe[incompatible-type]
22642262
effect.setKeyframes(keyframes);
22652263
// Read back the new animation to see what the underlying width/height of the pseudo-element was.
22662264
const computedStyle = getComputedStyle(
2267-
// $FlowFixMe
2265+
// $FlowFixMe[incompatible-type]
22682266
effect.target,
2269-
// $FlowFixMe
2267+
// $FlowFixMe[incompatible-type]
22702268
effect.pseudoElement,
22712269
);
22722270
if (
@@ -2281,7 +2279,7 @@ export function startViewTransition(
22812279
const last = keyframes[keyframes.length - 1];
22822280
last.width = width;
22832281
last.height = height;
2284-
// $FlowFixMe
2282+
// $FlowFixMe[incompatible-type]
22852283
effect.setKeyframes(keyframes);
22862284
}
22872285
}
@@ -2563,7 +2561,6 @@ export function startGestureTransition(
25632561
let longestDuration = 0;
25642562
for (let i = 0; i < animations.length; i++) {
25652563
const effect: KeyframeEffect = (animations[i].effect: any);
2566-
// $FlowFixMe
25672564
const pseudoElement: ?string = effect.pseudoElement;
25682565
if (pseudoElement == null) {
25692566
} else if (pseudoElement.startsWith('::view-transition')) {
@@ -2595,7 +2592,6 @@ export function startGestureTransition(
25952592
continue;
25962593
}
25972594
const effect: KeyframeEffect = (anim.effect: any);
2598-
// $FlowFixMe
25992595
const pseudoElement: ?string = effect.pseudoElement;
26002596
if (
26012597
pseudoElement != null &&
@@ -2655,7 +2651,7 @@ export function startGestureTransition(
26552651
}
26562652
animateGesture(
26572653
effect.getKeyframes(),
2658-
// $FlowFixMe: Always documentElement atm.
2654+
// $FlowFixMe[incompatible-type]: Always documentElement atm.
26592655
effect.target,
26602656
pseudoElement,
26612657
timeline,
@@ -2682,7 +2678,7 @@ export function startGestureTransition(
26822678
const pseudoElementName = '::view-transition-group' + groupName;
26832679
animateGesture(
26842680
[{}, {}],
2685-
// $FlowFixMe: Always documentElement atm.
2681+
// $FlowFixMe[incompatible-type]: Always documentElement atm.
26862682
effect.target,
26872683
pseudoElementName,
26882684
timeline,
@@ -4966,12 +4962,14 @@ function preinitStyle(
49664962
}
49674963

49684964
// Construct a Resource and cache it
4965+
// $FlowFixMe[incompatible-type]
49694966
resource = {
49704967
type: 'stylesheet',
49714968
instance,
49724969
count: 1,
49734970
state,
49744971
};
4972+
// $FlowFixMe[incompatible-type]
49754973
styles.set(key, resource);
49764974
return;
49774975
}

packages/react-dom-bindings/src/client/estimateBandwidth.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ export default function estimateBandwidth(): number {
9898
// Fallback to the navigator.connection estimate if available
9999
// $FlowFixMe[prop-missing]
100100
if (navigator.connection) {
101-
// $FlowFixMe
101+
// $FlowFixMe[prop-missing]
102+
// $FlowFixMe[incompatible-use]
102103
const downlink: ?number = navigator.connection.downlink;
103104
if (typeof downlink === 'number') {
104105
return downlink;

0 commit comments

Comments
 (0)