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