From afea1d0c536e0336735b0ea5c74f635527b65785 Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Mon, 27 Mar 2023 13:43:04 +0200 Subject: [PATCH] [flow] make Flow suppressions explicit on the error (#26487) Added an explicit type to all $FlowFixMe suppressions to reduce over-suppressions of new errors that might be caused on the same lines. Also removes suppressions that aren't used (e.g. in a `@noflow` file as they're purely misleading) Test Plan: yarn flow-ci --- packages/internal-test-utils/internalAct.js | 6 ++--- .../react-client/src/ReactFlightClient.js | 10 ++++---- .../src/ReactFlightReplyClient.js | 8 +++---- .../react-debug-tools/src/ReactDebugHooks.js | 6 ++--- .../src/__tests__/inspectedElement-test.js | 1 - .../__tests__/legacy/inspectElement-test.js | 1 - .../src/__tests__/setupTests.js | 2 -- .../storeStressTestConcurrent-test.js | 20 ---------------- .../src/__tests__/utils.js | 3 --- .../backend/DevToolsComponentStackFrame.js | 4 ++-- .../src/backend/DevToolsConsolePatching.js | 4 ++-- .../src/backend/profilingHooks.js | 6 ++--- .../src/backend/renderer.js | 2 +- .../src/backend/utils.js | 8 +++---- packages/react-devtools-shared/src/bridge.js | 4 ++-- .../src/devtools/views/Button.js | 2 +- .../NativeStyleEditor/AutoSizeInput.js | 2 +- .../views/Components/reach-ui/menu-button.js | 2 +- .../views/Components/reach-ui/tooltip.js | 2 +- .../views/Settings/SettingsContext.js | 2 +- .../src/devtools/views/utils.js | 2 +- .../src/registerDevToolsEventLogger.js | 5 ++-- packages/react-devtools-shared/src/utils.js | 2 +- .../app/InspectableElements/CustomHooks.js | 2 +- .../src/app/ReactNativeWeb/index.js | 1 - .../react-devtools-shell/src/app/devtools.js | 2 +- .../src/e2e-regression/devtools.js | 2 -- .../react-devtools-shell/src/e2e/devtools.js | 2 -- .../src/perf-regression/devtools.js | 1 - .../src/content-views/NativeEventsView.js | 2 +- .../src/content-views/NetworkMeasuresView.js | 2 +- .../src/content-views/SnapshotsView.js | 2 +- .../src/content-views/SuspenseEventsView.js | 2 +- .../src/import-worker/preprocessData.js | 4 ++-- .../src/client/DOMPropertyOperations.js | 2 +- .../src/client/ReactDOMComponent.js | 11 --------- .../src/client/ReactDOMHostConfig.js | 8 +++---- .../src/events/SyntheticEvent.js | 24 +++++++++---------- .../ReactDOMLegacyServerStreamConfig.js | 2 +- packages/react-dom/src/client/ReactDOM.js | 6 ++--- .../react-dom/src/client/ReactDOMLegacy.js | 2 +- .../src/server/ReactDOMFizzServerBrowser.js | 2 +- .../src/server/ReactDOMFizzServerBun.js | 2 +- .../src/server/ReactDOMFizzServerEdge.js | 2 +- .../src/server/ReactDOMFizzStaticBrowser.js | 2 +- .../src/server/ReactDOMFizzStaticEdge.js | 2 +- .../server/ReactDOMLegacyServerNodeStream.js | 1 - .../src/dom/create-event-handle/Focus.js | 8 +++---- .../react-native-renderer/src/ReactFabric.js | 1 - .../src/ReactNativeAttributePayload.js | 3 --- .../src/ReactNativeBridgeEventPlugin.js | 2 +- .../src/ReactNativeEventEmitter.js | 2 +- .../src/ReactNativeRenderer.js | 1 - .../src/legacy-events/accumulateInto.js | 5 ++-- .../src/createReactNoop.js | 3 --- packages/react-reconciler/src/DebugTracing.js | 2 +- .../react-reconciler/src/ReactChildFiber.js | 4 ++-- packages/react-reconciler/src/ReactFiber.js | 2 +- .../react-reconciler/src/ReactFiberAct.js | 2 +- .../src/ReactFiberCommitWork.js | 4 ++-- .../src/ReactFiberCompleteWork.js | 6 ++--- .../react-reconciler/src/ReactFiberHooks.js | 4 ++-- .../src/ReactFiberReconciler.js | 10 ++++---- .../src/ReactFiberWorkLoop.js | 2 +- .../src/ReactFlightDOMRelayClient.js | 18 +++++++++----- .../ReactFlightDOMRelayServerHostConfig.js | 7 ++---- .../src/ReactFlightDOMServerBrowser.js | 2 +- .../src/ReactFlightDOMServerEdge.js | 2 +- .../src/ReactFlightNativeRelayClient.js | 18 +++++++++----- .../ReactFlightNativeRelayServerHostConfig.js | 6 ++--- packages/react-server/src/ReactFizzHooks.js | 2 +- .../react-server/src/ReactFizzNewContext.js | 2 +- packages/react-server/src/ReactFizzServer.js | 1 - .../react-server/src/ReactFlightNewContext.js | 2 +- .../src/ReactFlightReplyServer.js | 4 ++-- .../react-server/src/ReactFlightServer.js | 8 +++---- .../src/ReactServerStreamConfigBrowser.js | 2 +- .../src/ReactServerStreamConfigBun.js | 2 +- .../src/ReactServerStreamConfigEdge.js | 2 +- .../src/ReactServerStreamConfigNode.js | 2 +- packages/react/src/ReactCache.js | 4 ++-- packages/react/src/ReactChildren.js | 6 ++--- packages/react/src/ReactContext.js | 4 ++-- packages/react/src/ReactFetch.js | 2 +- packages/react/src/ReactLazy.js | 6 ++--- packages/shared/CheckStringCoercion.js | 6 ++--- packages/shared/ConsolePatchingDev.js | 4 ++-- packages/shared/ReactComponentStackFrame.js | 4 ++-- packages/shared/ReactServerContextRegistry.js | 2 +- packages/shared/checkPropTypes.js | 2 +- 90 files changed, 164 insertions(+), 209 deletions(-) diff --git a/packages/internal-test-utils/internalAct.js b/packages/internal-test-utils/internalAct.js index 9b13d371d493a..6794e1b64cec8 100644 --- a/packages/internal-test-utils/internalAct.js +++ b/packages/internal-test-utils/internalAct.js @@ -35,7 +35,7 @@ export async function act(scope: () => Thenable): Thenable { ); } - // $FlowFixMe: Flow doesn't know about global Jest object + // $FlowFixMe[cannot-resolve-name]: Flow doesn't know about global Jest object if (!jest.isMockFunction(setTimeout)) { throw Error( "This version of `act` requires Jest's timer mocks " + @@ -70,7 +70,7 @@ export async function act(scope: () => Thenable): Thenable { // Wait until end of current task/microtask. await waitForMicrotasks(); - // $FlowFixMe: Flow doesn't know about global Jest object + // $FlowFixMe[cannot-resolve-name]: Flow doesn't know about global Jest object if (jest.isEnvironmentTornDown()) { error.message = 'The Jest environment was torn down before `act` completed. This ' + @@ -79,7 +79,7 @@ export async function act(scope: () => Thenable): Thenable { } if (!Scheduler.unstable_hasPendingWork()) { - // $FlowFixMe: Flow doesn't know about global Jest object + // $FlowFixMe[cannot-resolve-name]: Flow doesn't know about global Jest object jest.runOnlyPendingTimers(); if (Scheduler.unstable_hasPendingWork()) { // Committing a fallback scheduled additional work. Continue flushing. diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index cded0a689a729..2657064dd8af1 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -189,12 +189,12 @@ export function getRoot(response: Response): Thenable { } function createPendingChunk(response: Response): PendingChunk { - // $FlowFixMe Flow doesn't support functions as constructors + // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors return new Chunk(PENDING, null, null, response); } function createBlockedChunk(response: Response): BlockedChunk { - // $FlowFixMe Flow doesn't support functions as constructors + // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors return new Chunk(BLOCKED, null, null, response); } @@ -202,7 +202,7 @@ function createErrorChunk( response: Response, error: ErrorWithDigest, ): ErroredChunk { - // $FlowFixMe Flow doesn't support functions as constructors + // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors return new Chunk(ERRORED, null, error, response); } @@ -253,7 +253,7 @@ function createResolvedModelChunk( response: Response, value: UninitializedModel, ): ResolvedModelChunk { - // $FlowFixMe Flow doesn't support functions as constructors + // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors return new Chunk(RESOLVED_MODEL, value, null, response); } @@ -261,7 +261,7 @@ function createResolvedModuleChunk( response: Response, value: ClientReference, ): ResolvedModuleChunk { - // $FlowFixMe Flow doesn't support functions as constructors + // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors return new Chunk(RESOLVED_MODULE, value, null, response); } diff --git a/packages/react-client/src/ReactFlightReplyClient.js b/packages/react-client/src/ReactFlightReplyClient.js index 99cade0bc1798..d08af17f374d5 100644 --- a/packages/react-client/src/ReactFlightReplyClient.js +++ b/packages/react-client/src/ReactFlightReplyClient.js @@ -103,7 +103,7 @@ export function processReply( ): ReactJSONValue { const parent = this; if (__DEV__) { - // $FlowFixMe + // $FlowFixMe[incompatible-use] const originalValue = this[key]; if (typeof originalValue === 'object' && originalValue !== value) { if (objectName(originalValue) !== 'Object') { @@ -212,7 +212,7 @@ export function processReply( } } - // $FlowFixMe + // $FlowFixMe[incompatible-return] return value; } @@ -249,13 +249,13 @@ export function processReply( } if (typeof value === 'symbol') { - // $FlowFixMe `description` might be undefined + // $FlowFixMe[incompatible-type] `description` might be undefined const name: string = value.description; if (Symbol.for(name) !== value) { throw new Error( 'Only global symbols received from Symbol.for(...) can be passed to Server Functions. ' + `The symbol Symbol.for(${ - // $FlowFixMe `description` might be undefined + // $FlowFixMe[incompatible-type] `description` might be undefined value.description }) cannot be found among global symbols.`, ); diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index c6ee8a6d25192..44d99922dfbc9 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -123,7 +123,7 @@ function useState( hook !== null ? hook.memoizedState : typeof initialState === 'function' - ? // $FlowFixMe: Flow doesn't like mixed types + ? // $FlowFixMe[incompatible-use]: Flow doesn't like mixed types initialState() : initialState; hookLog.push({primitive: 'State', stackError: new Error(), value: state}); @@ -674,7 +674,7 @@ function handleRenderFunctionError(error: any): void { // that the error is caused by user's code in renderFunction. // In this case, we should wrap the original error inside a custom error // so that devtools can give a clear message about it. - // $FlowFixMe: Flow doesn't know about 2nd argument of Error constructor + // $FlowFixMe[extra-arg]: Flow doesn't know about 2nd argument of Error constructor const wrapperError = new Error('Error rendering inspected component', { cause: error, }); @@ -682,7 +682,7 @@ function handleRenderFunctionError(error: any): void { // TODO: refactor this if we ever combine the devtools and debug tools packages wrapperError.name = 'ReactDebugToolsRenderError'; // this stage-4 proposal is not supported by all environments yet. - // $FlowFixMe Flow doesn't have this type yet. + // $FlowFixMe[prop-missing] Flow doesn't have this type yet. wrapperError.cause = error; throw wrapperError; } diff --git a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js index 19c836a91ad75..b88c01868b03b 100644 --- a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js +++ b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js @@ -1841,7 +1841,6 @@ describe('InspectedElement', () => { xyz: 1, }, }); - // $FlowFixMe const bigInt = BigInt(123); // eslint-disable-line no-undef await utils.actAsync(() => diff --git a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js index ba8064bc3ca3a..6b622af2bfc39 100644 --- a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js +++ b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js @@ -873,7 +873,6 @@ describe('InspectedElementContext', () => { xyz: 1, }, }); - // $FlowFixMe const bigInt = BigInt(123); // eslint-disable-line no-undef act(() => diff --git a/packages/react-devtools-shared/src/__tests__/setupTests.js b/packages/react-devtools-shared/src/__tests__/setupTests.js index 309690983d6f8..614c3a8ef88c2 100644 --- a/packages/react-devtools-shared/src/__tests__/setupTests.js +++ b/packages/react-devtools-shared/src/__tests__/setupTests.js @@ -80,7 +80,6 @@ beforeEach(() => { } const originalConsoleError = console.error; - // $FlowFixMe console.error = (...args) => { const firstArg = args[0]; if ( @@ -111,7 +110,6 @@ beforeEach(() => { originalConsoleError.apply(console, args); }; const originalConsoleWarn = console.warn; - // $FlowFixMe console.warn = (...args) => { if (shouldIgnoreConsoleErrorOrWarn(args)) { // Allows testing how DevTools behaves when it encounters console.warn without cluttering the test output. diff --git a/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js b/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js index afeeaf9db839a..7d366bd9ac6e9 100644 --- a/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js +++ b/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js @@ -67,7 +67,6 @@ describe('StoreStressConcurrent', () => { // 1. Render a normal version of [a, b, c, d, e]. let container = document.createElement('div'); - // $FlowFixMe let root = ReactDOMClient.createRoot(container); act(() => root.render({[a, b, c, d, e]})); expect(store).toMatchInlineSnapshot( @@ -151,7 +150,6 @@ describe('StoreStressConcurrent', () => { for (let i = 0; i < cases.length; i++) { // Ensure fresh mount. container = document.createElement('div'); - // $FlowFixMe root = ReactDOMClient.createRoot(container); // Verify mounting 'abcde'. @@ -181,7 +179,6 @@ describe('StoreStressConcurrent', () => { // 6. Verify *updates* by reusing the container between iterations. // There'll be no unmounting until the very end. container = document.createElement('div'); - // $FlowFixMe root = ReactDOMClient.createRoot(container); for (let i = 0; i < cases.length; i++) { // Verify mounting 'abcde'. @@ -249,7 +246,6 @@ describe('StoreStressConcurrent', () => { const snapshots = []; let container = document.createElement('div'); for (let i = 0; i < steps.length; i++) { - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render({steps[i]})); // We snapshot each step once so it doesn't regress. @@ -321,7 +317,6 @@ describe('StoreStressConcurrent', () => { for (let i = 0; i < steps.length; i++) { for (let j = 0; j < steps.length; j++) { container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render({steps[i]})); expect(print(store)).toMatch(snapshots[i]); @@ -338,7 +333,6 @@ describe('StoreStressConcurrent', () => { for (let i = 0; i < steps.length; i++) { for (let j = 0; j < steps.length; j++) { container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -412,7 +406,6 @@ describe('StoreStressConcurrent', () => { const snapshots = []; let container = document.createElement('div'); for (let i = 0; i < steps.length; i++) { - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -515,7 +508,6 @@ describe('StoreStressConcurrent', () => { // 2. Verify check Suspense can render same steps as initial fallback content. for (let i = 0; i < steps.length; i++) { - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -540,7 +532,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -586,7 +577,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -644,7 +634,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -694,7 +683,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -748,7 +736,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -904,7 +891,6 @@ describe('StoreStressConcurrent', () => { const snapshots = []; let container = document.createElement('div'); for (let i = 0; i < steps.length; i++) { - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -928,7 +914,6 @@ describe('StoreStressConcurrent', () => { // which is different from the snapshots above. So we take more snapshots. const fallbackSnapshots = []; for (let i = 0; i < steps.length; i++) { - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -1062,7 +1047,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -1114,7 +1098,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -1181,7 +1164,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -1233,7 +1215,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( @@ -1285,7 +1266,6 @@ describe('StoreStressConcurrent', () => { for (let j = 0; j < steps.length; j++) { // Always start with a fresh container and steps[i]. container = document.createElement('div'); - // $FlowFixMe const root = ReactDOMClient.createRoot(container); act(() => root.render( diff --git a/packages/react-devtools-shared/src/__tests__/utils.js b/packages/react-devtools-shared/src/__tests__/utils.js index 59b92659b8f44..8b2da7722e340 100644 --- a/packages/react-devtools-shared/src/__tests__/utils.js +++ b/packages/react-devtools-shared/src/__tests__/utils.js @@ -46,7 +46,6 @@ export async function actAsync( const {act: actTestRenderer} = require('react-test-renderer'); const {act: actDOM} = require('react-dom/test-utils'); - // $FlowFixMe Flow doesn't know about "await act()" yet await actDOM(async () => { await actTestRenderer(async () => { await cb(); @@ -55,7 +54,6 @@ export async function actAsync( if (recursivelyFlush) { while (jest.getTimerCount() > 0) { - // $FlowFixMe Flow doesn't know about "await act()" yet await actDOM(async () => { await actTestRenderer(async () => { jest.runAllTimers(); @@ -63,7 +61,6 @@ export async function actAsync( }); } } else { - // $FlowFixMe Flow doesn't know about "await act()" yet await actDOM(async () => { await actTestRenderer(async () => { jest.runOnlyPendingTimers(); diff --git a/packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js b/packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js index a6aacaeec8955..98d944477d860 100644 --- a/packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js +++ b/packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js @@ -77,7 +77,7 @@ export function describeNativeComponentFrame( let control; const previousPrepareStackTrace = Error.prepareStackTrace; - // $FlowFixMe It does accept undefined. + // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; reentry = true; @@ -98,7 +98,7 @@ export function describeNativeComponentFrame( const Fake = function () { throw Error(); }; - // $FlowFixMe + // $FlowFixMe[prop-missing] Object.defineProperty(Fake.prototype, 'props', { set: function () { // We use a throwing setter instead of frozen or non-writable props diff --git a/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js b/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js index 5bd09b7369337..bc133590f89b8 100644 --- a/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js +++ b/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js @@ -45,7 +45,7 @@ export function disableLogs(): void { value: disabledLog, writable: true, }; - // $FlowFixMe Flow thinks console is immutable. + // $FlowFixMe[cannot-write] Flow thinks console is immutable. Object.defineProperties(console, { info: props, log: props, @@ -69,7 +69,7 @@ export function reenableLogs(): void { enumerable: true, writable: true, }; - // $FlowFixMe Flow thinks console is immutable. + // $FlowFixMe[cannot-write] Flow thinks console is immutable. Object.defineProperties(console, { log: {...props, value: prevLog}, info: {...props, value: prevInfo}, diff --git a/packages/react-devtools-shared/src/backend/profilingHooks.js b/packages/react-devtools-shared/src/backend/profilingHooks.js index 95ebb50734949..585ed5753d3ce 100644 --- a/packages/react-devtools-shared/src/backend/profilingHooks.js +++ b/packages/react-devtools-shared/src/backend/profilingHooks.js @@ -64,7 +64,7 @@ if (supportsUserTiming) { }); try { - // $FlowFixMe: Flow expects the User Timing level 2 API. + // $FlowFixMe[extra-arg]: Flow expects the User Timing level 2 API. performance.mark(CHECK_V3_MARK, markOptions); } catch (error) { // Ignore @@ -281,7 +281,7 @@ export function createProfilingHooks({ ); } - // $FlowFixMe This property should not be writable outside of this function. + // $FlowFixMe[cannot-write] This property should not be writable outside of this function. top.duration = currentTime - top.timestamp; if (currentTimelineData) { @@ -590,7 +590,7 @@ export function createProfilingHooks({ const PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; - // $FlowFixMe: Flow cannot handle polymorphic WeakMaps + // $FlowFixMe[incompatible-type]: Flow cannot handle polymorphic WeakMaps const wakeableIDs: WeakMap = new PossiblyWeakMap(); let wakeableID: number = 0; function getWakeableID(wakeable: Wakeable): number { diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index abd1327c0de01..00558a4bf77fa 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -384,7 +384,7 @@ export function getInternalReactConstants(version: string): { typeof type === 'object' && type !== null ? type.$$typeof : type; return typeof symbolOrNumber === 'symbol' - ? // $FlowFixMe `toString()` doesn't match the type signature? + ? // $FlowFixMe[incompatible-return] `toString()` doesn't match the type signature? symbolOrNumber.toString() : symbolOrNumber; } diff --git a/packages/react-devtools-shared/src/backend/utils.js b/packages/react-devtools-shared/src/backend/utils.js index f5979a9d5836d..22bfe1131da5b 100644 --- a/packages/react-devtools-shared/src/backend/utils.js +++ b/packages/react-devtools-shared/src/backend/utils.js @@ -72,7 +72,7 @@ export function copyWithDelete( delete updated[key]; } } else { - // $FlowFixMe number or string is fine here + // $FlowFixMe[incompatible-use] number or string is fine here updated[key] = copyWithDelete(obj[key], path, index + 1); } return updated; @@ -90,7 +90,7 @@ export function copyWithRename( const updated = isArray(obj) ? obj.slice() : {...obj}; if (index + 1 === oldPath.length) { const newKey = newPath[index]; - // $FlowFixMe number or string is fine here + // $FlowFixMe[incompatible-use] number or string is fine here updated[newKey] = updated[oldKey]; if (isArray(updated)) { updated.splice(((oldKey: any): number), 1); @@ -98,7 +98,7 @@ export function copyWithRename( delete updated[oldKey]; } } else { - // $FlowFixMe number or string is fine here + // $FlowFixMe[incompatible-use] number or string is fine here updated[oldKey] = copyWithRename(obj[oldKey], oldPath, newPath, index + 1); } return updated; @@ -115,7 +115,7 @@ export function copyWithSet( } const key = path[index]; const updated = isArray(obj) ? obj.slice() : {...obj}; - // $FlowFixMe number or string is fine here + // $FlowFixMe[incompatible-use] number or string is fine here updated[key] = copyWithSet(obj[key], path, value, index + 1); return updated; } diff --git a/packages/react-devtools-shared/src/bridge.js b/packages/react-devtools-shared/src/bridge.js index cc70ba6785246..c2dd07d393ea9 100644 --- a/packages/react-devtools-shared/src/bridge.js +++ b/packages/react-devtools-shared/src/bridge.js @@ -339,9 +339,9 @@ class Bridge< this._isShutdown = true; // Disable the API inherited from EventEmitter that can add more listeners and send more messages. - // $FlowFixMe This property is not writable. + // $FlowFixMe[cannot-write] This property is not writable. this.addListener = function () {}; - // $FlowFixMe This property is not writable. + // $FlowFixMe[cannot-write] This property is not writable. this.emit = function () {}; // NOTE: There's also EventEmitter API like `on` and `prependListener` that we didn't add to our Flow type of EventEmitter. diff --git a/packages/react-devtools-shared/src/devtools/views/Button.js b/packages/react-devtools-shared/src/devtools/views/Button.js index 0ddb608017aff..a07aa8796e6f8 100644 --- a/packages/react-devtools-shared/src/devtools/views/Button.js +++ b/packages/react-devtools-shared/src/devtools/views/Button.js @@ -28,7 +28,7 @@ export default function Button({ ...rest }: Props): React.Node { let button = ( - // $FlowFixMe unsafe spread + // $FlowFixMe[cannot-spread-inexact] unsafe spread