From 6c563a507fd8c41e04a1e62e2ba87993c6eb1e2f Mon Sep 17 00:00:00 2001 From: Pieter Vanderwerff Date: Thu, 7 Jul 2022 21:53:53 -0700 Subject: [PATCH] Suppress missing 'this' annotations in xplat/js Reviewed By: samwgoldman Differential Revision: D37701888 fbshipit-source-id: 80cf21e4c942f00695c08ea8671efba0109aad32 --- Libraries/Components/Touchable/PooledClass.js | 10 +++++ Libraries/Components/Touchable/Touchable.js | 38 +++++++++++++++++++ Libraries/Storage/AsyncStorage.js | 4 ++ Libraries/StyleSheet/processTransform.js | 2 + Libraries/Utilities/stringifySafe.js | 2 + .../emitter/__tests__/EventEmitter-test.js | 2 + packages/polyfills/error-guard.js | 2 + .../examples/AnimatedGratuitousApp/AnExApp.js | 2 + 8 files changed, 62 insertions(+) diff --git a/Libraries/Components/Touchable/PooledClass.js b/Libraries/Components/Touchable/PooledClass.js index 3b0c41c9f95be6..67847c1ba0c095 100644 --- a/Libraries/Components/Touchable/PooledClass.js +++ b/Libraries/Components/Touchable/PooledClass.js @@ -18,6 +18,8 @@ import invariant from 'invariant'; * the Class itself, not an instance. If any others are needed, simply add them * here, or in their own files. */ +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const oneArgumentPooler = function (copyFieldsFrom: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { @@ -29,6 +31,8 @@ const oneArgumentPooler = function (copyFieldsFrom: any) { } }; +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const twoArgumentPooler = function (a1: any, a2: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { @@ -40,6 +44,8 @@ const twoArgumentPooler = function (a1: any, a2: any) { } }; +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const threeArgumentPooler = function (a1: any, a2: any, a3: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { @@ -51,6 +57,8 @@ const threeArgumentPooler = function (a1: any, a2: any, a3: any) { } }; +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const fourArgumentPooler = function (a1: any, a2: any, a3: any, a4: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { @@ -64,6 +72,8 @@ const fourArgumentPooler = function (a1: any, a2: any, a3: any, a4: any) { /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's * LTI update could not be added via codemod */ +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const standardReleaser = function (instance) { const Klass = this; // eslint-disable-line consistent-this invariant( diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index b4ec927840fe37..ea448b3efb50c1 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -381,6 +381,8 @@ const TouchableMixin = { /** * Clear all timeouts on unmount */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ componentWillUnmount: function () { this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout); this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout); @@ -406,6 +408,8 @@ const TouchableMixin = { /** * Must return true if embedded in a native platform scroll view. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderTerminationRequest: function (): any { return !this.props.rejectResponderTermination; }, @@ -413,6 +417,8 @@ const TouchableMixin = { /** * Must return true to start the process of `Touchable`. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleStartShouldSetResponder: function (): any { return !this.props.disabled; }, @@ -429,6 +435,8 @@ const TouchableMixin = { * @param {SyntheticEvent} e Synthetic event from event system. * */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderGrant: function (e: PressEvent) { const dispatchID = e.currentTarget; // Since e is used in a callback invoked on another event loop @@ -470,6 +478,8 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderRelease` event. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderRelease: function (e: PressEvent) { this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_RELEASE, e); @@ -478,6 +488,8 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderTerminate` event. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderTerminate: function (e: PressEvent) { this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_TERMINATED, e); @@ -486,6 +498,8 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderMove` event. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderMove: function (e: PressEvent) { // Measurement may not have returned yet. if (!this.state.touchable.positionOnActivate) { @@ -571,6 +585,8 @@ const TouchableMixin = { * element that was blurred just prior to this. This can be overridden when * using `Touchable.Mixin.withoutDefaultFocusAndBlur`. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleFocus: function (e: Event) { this.props.onFocus && this.props.onFocus(e); }, @@ -583,6 +599,8 @@ const TouchableMixin = { * This can be overridden when using * `Touchable.Mixin.withoutDefaultFocusAndBlur`. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleBlur: function (e: Event) { this.props.onBlur && this.props.onBlur(e); }, @@ -663,6 +681,8 @@ const TouchableMixin = { * @sideeffects * @private */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _remeasureMetricsOnActivation: function () { const responderID = this.state.touchable.responderID; if (responderID == null) { @@ -676,6 +696,8 @@ const TouchableMixin = { } }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _handleQueryLayout: function ( l: number, t: number, @@ -702,11 +724,15 @@ const TouchableMixin = { ); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _handleDelay: function (e: PressEvent) { this.touchableDelayTimeout = null; this._receiveSignal(Signals.DELAY, e); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _handleLongDelay: function (e: PressEvent) { this.longPressDelayTimeout = null; const curState = this.state.touchable.touchState; @@ -726,6 +752,8 @@ const TouchableMixin = { * @throws Error if invalid state transition or unrecognized signal. * @sideeffects */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _receiveSignal: function (signal: Signal, e: PressEvent) { const responderID = this.state.touchable.responderID; const curState = this.state.touchable.touchState; @@ -765,6 +793,8 @@ const TouchableMixin = { } }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _cancelLongPressDelayTimeout: function () { this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout); this.longPressDelayTimeout = null; @@ -777,6 +807,8 @@ const TouchableMixin = { ); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _savePressInLocation: function (e: PressEvent) { const touch = extractSingleTouch(e.nativeEvent); const pageX = touch && touch.pageX; @@ -808,6 +840,8 @@ const TouchableMixin = { * @param {Event} e Native event. * @sideeffects */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _performSideEffectsForTransition: function ( curState: State, nextState: State, @@ -869,11 +903,15 @@ const TouchableMixin = { this.touchableDelayTimeout = null; }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _startHighlight: function (e: PressEvent) { this._savePressInLocation(e); this.touchableHandleActivePressIn && this.touchableHandleActivePressIn(e); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _endHighlight: function (e: PressEvent) { if (this.touchableHandleActivePressOut) { if ( diff --git a/Libraries/Storage/AsyncStorage.js b/Libraries/Storage/AsyncStorage.js index 6b433b0387bf1a..e9683ab0cf7a7e 100644 --- a/Libraries/Storage/AsyncStorage.js +++ b/Libraries/Storage/AsyncStorage.js @@ -198,6 +198,8 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage#flushgetrequests * */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ flushGetRequests: function (): void { const getRequests = this._getRequests; const getKeys = this._getKeys; @@ -237,6 +239,8 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage#multiget */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ multiGet: function ( keys: Array, callback?: ?(errors: ?Array, result: ?Array>) => void, diff --git a/Libraries/StyleSheet/processTransform.js b/Libraries/StyleSheet/processTransform.js index c05375bd591205..8edb62d853c3e6 100644 --- a/Libraries/StyleSheet/processTransform.js +++ b/Libraries/StyleSheet/processTransform.js @@ -116,6 +116,8 @@ function processTransform( /** * Performs a destructive operation on a transform matrix. */ +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ function _multiplyTransform( result: Array, matrixMathFunction: Function, diff --git a/Libraries/Utilities/stringifySafe.js b/Libraries/Utilities/stringifySafe.js index 4fafb00f9a2a90..922ce9bd8bcb51 100644 --- a/Libraries/Utilities/stringifySafe.js +++ b/Libraries/Utilities/stringifySafe.js @@ -27,6 +27,8 @@ export function createStringifySafeWithLimits(limits: {| maxObjectKeysLimit = Number.POSITIVE_INFINITY, } = limits; const stack = []; + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ function replacer(key: string, value: mixed): mixed { while (stack.length && this !== stack[0]) { stack.shift(); diff --git a/Libraries/vendor/emitter/__tests__/EventEmitter-test.js b/Libraries/vendor/emitter/__tests__/EventEmitter-test.js index c0ba1fd636cadf..2fdd9b1385305a 100644 --- a/Libraries/vendor/emitter/__tests__/EventEmitter-test.js +++ b/Libraries/vendor/emitter/__tests__/EventEmitter-test.js @@ -118,6 +118,8 @@ describe('arguments and context', () => { const context = {}; let result; + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const listener = jest.fn(function () { result = this; }); diff --git a/packages/polyfills/error-guard.js b/packages/polyfills/error-guard.js index d94274721a08bf..389b5a20f81477 100644 --- a/packages/polyfills/error-guard.js +++ b/packages/polyfills/error-guard.js @@ -102,6 +102,8 @@ const ErrorUtils = { return null; } const guardName = name ?? fun.name ?? ''; + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ function guarded(...args: TArgs): ?TOut { return ErrorUtils.applyWithGuard( fun, diff --git a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js index 8d2bc6ae1d89f9..52d081b7b9eab4 100644 --- a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js +++ b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js @@ -237,6 +237,8 @@ class AnExApp extends React.Component { if (!this.state.restLayouts[idx]) { /* $FlowFixMe[missing-local-annot] The type annotation(s) required by * Flow's LTI update could not be added via codemod */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) + * required by Flow's LTI update could not be added via codemod */ onLayout = function (index, e) { const layout = e.nativeEvent.layout; this.setState(state => {