From 680ad6dedef78ebcff66e451488fd52c29269612 Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Mon, 1 Jul 2024 16:45:26 -0400 Subject: [PATCH] Fix Flow issues in Replay RDT fork --- packages/react-devtools-extensions/src/backend.js | 6 +++--- packages/react-devtools-shared/src/backend/agent.js | 4 ++-- packages/react-devtools-shared/src/backend/console.js | 6 +++++- packages/react-devtools-shared/src/backend/renderer.js | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/react-devtools-extensions/src/backend.js b/packages/react-devtools-extensions/src/backend.js index a506c590d2f04..7cf684365f95c 100644 --- a/packages/react-devtools-extensions/src/backend.js +++ b/packages/react-devtools-extensions/src/backend.js @@ -24,9 +24,9 @@ function setup(hook: ?DevToolsHook) { return; } - const bridge = new Bridge({ + const bridge = new Bridge({ listen(fn) { - const listener = event => { + const listener = (event: any) => { if ( event.source !== window || !event.data || @@ -42,7 +42,7 @@ function setup(hook: ?DevToolsHook) { window.removeEventListener('message', listener); }; }, - send(event, payload, transferable) { + send(event: string, payload: any, transferable: any) { window.postMessage( { source: 'react-devtools-bridge', diff --git a/packages/react-devtools-shared/src/backend/agent.js b/packages/react-devtools-shared/src/backend/agent.js index 6383f022624ca..d054bd845ed3b 100644 --- a/packages/react-devtools-shared/src/backend/agent.js +++ b/packages/react-devtools-shared/src/backend/agent.js @@ -216,11 +216,11 @@ export default class Agent extends EventEmitter<{ inData, ) => { let rv; - this._bridge = { + this._bridge = ({ send(event, data) { rv = {event, data}; }, - }; + }: any); try { this[inEvent](inData); } catch (err) { diff --git a/packages/react-devtools-shared/src/backend/console.js b/packages/react-devtools-shared/src/backend/console.js index e1b98b9190129..c2ce574991abf 100644 --- a/packages/react-devtools-shared/src/backend/console.js +++ b/packages/react-devtools-shared/src/backend/console.js @@ -136,7 +136,11 @@ export function registerRenderer( // currentDispatcherRef gets injected for v16.8+ to support hooks inspection. // getCurrentFiber gets injected for v16.9+. if (currentDispatcherRef != null && typeof getCurrentFiber === 'function') { - const {ReactTypeOfWork} = getInternalReactConstants(version); + const {ReactTypeOfWork} = getInternalReactConstants( + version, + // REPLAY Our fork will never run this code anyway, make Flow happy + () => 0, + ); injectedRenderers.set(renderer, { currentDispatcherRef, diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index c32a968bf9875..bce19e3b7eee9 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -2485,7 +2485,7 @@ export function attach( if ( mostRecentlyInspectedElement !== null && mostRecentlyInspectedElement.id === id && - fiberRenderered + fiberRendered ) { // If this Fiber has updated, clear cached inspected data. // If it is inspected again, it may need to be re-run to obtain updated hooks values.