From 91e832802cdbaa1ffdd1f10ffe64fffd74ffa7cc Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Mon, 4 Mar 2024 12:42:12 +0100 Subject: [PATCH] fix(dev-middleware): allow passing `?Page | ?PageWithMiddleware` to `Device` functions and properties --- packages/dev-middleware/src/inspector-proxy/Device.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/dev-middleware/src/inspector-proxy/Device.js b/packages/dev-middleware/src/inspector-proxy/Device.js index 793cfdf4137344..1df49c75a48169 100644 --- a/packages/dev-middleware/src/inspector-proxy/Device.js +++ b/packages/dev-middleware/src/inspector-proxy/Device.js @@ -86,7 +86,7 @@ export default class Device { // Last known Page ID of the React Native page. // This is used by debugger connections that don't have PageID specified // (and will interact with the latest React Native page). - #lastConnectedLegacyReactNativePage: ?Page = null; + #lastConnectedLegacyReactNativePage: ?Page | ?PageWithMiddleware = null; // Whether we are in the middle of a reload in the REACT_NATIVE_RELOADABLE_PAGE. #isLegacyPageReloading: boolean = false; @@ -333,7 +333,10 @@ export default class Device { /** * Returns `true` if a page supports the given target capability flag. */ - #pageHasCapability(page: Page, flag: $Keys): boolean { + #pageHasCapability( + page: Page | PageWithMiddleware, + flag: $Keys, + ): boolean { return page.capabilities[flag] === true; } @@ -495,7 +498,7 @@ export default class Device { } // We received new React Native Page ID. - #newLegacyReactNativePage(page: Page) { + #newLegacyReactNativePage(page: Page | PageWithMiddleware) { debug(`React Native page updated to ${page.id}`); if ( this.#debuggerConnection == null ||