Skip to content

Commit

Permalink
Suppress missing 'this' annotations in xplat/js
Browse files Browse the repository at this point in the history
Reviewed By: samwgoldman

Differential Revision: D37701888

fbshipit-source-id: 80cf21e4c942f00695c08ea8671efba0109aad32
  • Loading branch information
pieterv authored and facebook-github-bot committed Jul 8, 2022
1 parent 08f6b85 commit 6c563a5
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Libraries/Components/Touchable/PooledClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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(
Expand Down
38 changes: 38 additions & 0 deletions Libraries/Components/Touchable/Touchable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -406,13 +408,17 @@ 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;
},

/**
* 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;
},
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
},
Expand All @@ -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);
},
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 (
Expand Down
4 changes: 4 additions & 0 deletions Libraries/Storage/AsyncStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string>,
callback?: ?(errors: ?Array<Error>, result: ?Array<Array<string>>) => void,
Expand Down
2 changes: 2 additions & 0 deletions Libraries/StyleSheet/processTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>,
matrixMathFunction: Function,
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Utilities/stringifySafe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions Libraries/vendor/emitter/__tests__/EventEmitter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
2 changes: 2 additions & 0 deletions packages/polyfills/error-guard.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const ErrorUtils = {
return null;
}
const guardName = name ?? fun.name ?? '<generated guard>';
/* $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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ class AnExApp extends React.Component<any, any> {
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 => {
Expand Down

0 comments on commit 6c563a5

Please sign in to comment.