mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Turn on experimental.new_this_typing in xplat (#58293)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/58293 Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D118513884 fbshipit-source-id: a33a81eab930ac29663410cf04163aebb87062ad
This commit is contained in:
1 parent
c148be6ece
commit
fdcce4f673
16 files changed
+82
No files matched your search
@@ -500,6 +500,8 @@ export default class Device {
|
||||
// $FlowFixMe[cannot-write]
|
||||
socket.send = function (message: string) {
|
||||
cdpDebugLogging.log('ProxyToDebugger', message);
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
return sendFunc.call(socket, message);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -237,6 +237,8 @@ describe('AnimatedValue', () => {
|
||||
// $FlowFixMe[method-unbinding]
|
||||
const original = node.__onAnimatedValueUpdateReceived;
|
||||
const spy = jest.fn((...args: Array<unknown>) =>
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
original.apply(node, args),
|
||||
);
|
||||
// $FlowFixMe[cannot-write]
|
||||
|
||||
@@ -384,4 +384,6 @@ export default class AnimatedProps extends AnimatedNode {
|
||||
const _hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
const hasOwn: (obj: Readonly<{...}>, prop: string) => boolean =
|
||||
// $FlowFixMe[method-unbinding]
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Object.hasOwn ?? ((obj, prop) => _hasOwnProp.call(obj, prop));
|
||||
@@ -255,4 +255,6 @@ export default class AnimatedStyle extends AnimatedWithChildren {
|
||||
const _hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
const hasOwn: (obj: Readonly<{...}>, prop: string) => boolean =
|
||||
// $FlowFixMe[method-unbinding]
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Object.hasOwn ?? ((obj, prop) => _hasOwnProp.call(obj, prop));
|
||||
@@ -1069,6 +1069,8 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
|
||||
nodeHandle,
|
||||
nullthrows(findNodeHandle<$FlowFixMe>(this)),
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this
|
||||
* typing unsoundness in flow */
|
||||
this._textInputFocusError,
|
||||
this._inputMeasureAndScrollToKeyboard,
|
||||
);
|
||||
@@ -1077,6 +1079,8 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
|
||||
this._innerView.nativeInstance,
|
||||
this._inputMeasureAndScrollToKeyboard,
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this
|
||||
* typing unsoundness in flow */
|
||||
this._textInputFocusError,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -339,6 +339,8 @@ class Modal extends React.Component<ModalProps, ModalState> {
|
||||
identifier={this._identifier}
|
||||
style={styles.modal}
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
onStartShouldSetResponder={this._shouldSetResponder}
|
||||
supportedOrientations={this.props.supportedOrientations}
|
||||
onOrientationChange={this.props.onOrientationChange}
|
||||
|
||||
+4
@@ -49,6 +49,8 @@ function deepFreezeAndThrowOnMutationInDev<T extends {...} | Array<unknown>>(
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
if (hasOwnProperty.call(object, key)) {
|
||||
Object.defineProperty(object, key, {
|
||||
get: identity.bind(null, object[key]),
|
||||
@@ -64,6 +66,8 @@ function deepFreezeAndThrowOnMutationInDev<T extends {...} | Array<unknown>>(
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
if (hasOwnProperty.call(object, key)) {
|
||||
deepFreezeAndThrowOnMutationInDev(object[key]);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,13 @@ const rejectionTrackingOptions: NonNullable<Parameters<enable>[0]> = {
|
||||
message = '';
|
||||
} else if (
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Object.prototype.toString.call(rejection) === '[object Error]'
|
||||
) {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
message = Error.prototype.toString.call(rejection);
|
||||
} else {
|
||||
try {
|
||||
|
||||
@@ -357,4 +357,6 @@ function areCompositeKeyComponentsEqual(
|
||||
const _hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
const hasOwn: (obj: Readonly<{...}>, prop: string) => boolean =
|
||||
// $FlowFixMe[method-unbinding]
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Object.hasOwn ?? ((obj, prop) => _hasOwnProp.call(obj, prop));
|
||||
+6
@@ -122,6 +122,8 @@ const XHRInterceptor = {
|
||||
if (openCallback) {
|
||||
openCallback(method, url, this);
|
||||
}
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
originalXHROpen.apply(this, arguments);
|
||||
};
|
||||
|
||||
@@ -136,6 +138,8 @@ const XHRInterceptor = {
|
||||
if (requestHeaderCallback) {
|
||||
requestHeaderCallback(header, value, this);
|
||||
}
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
originalXHRSetRequestHeader.apply(this, arguments);
|
||||
};
|
||||
|
||||
@@ -190,6 +194,8 @@ const XHRInterceptor = {
|
||||
false,
|
||||
);
|
||||
}
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
originalXHRSend.apply(this, arguments);
|
||||
};
|
||||
isInterceptorEnabled = true;
|
||||
|
||||
+6
@@ -81,6 +81,8 @@ describe('AbortController', () => {
|
||||
|
||||
it('should be stringified as [object AbortController]', () => {
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
expect(Object.prototype.toString.call(controller)).toBe(
|
||||
'[object AbortController]',
|
||||
);
|
||||
@@ -171,6 +173,8 @@ describe('AbortController', () => {
|
||||
|
||||
it('should be stringified as [object AbortSignal]', () => {
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
expect(Object.prototype.toString.call(signal)).toBe(
|
||||
'[object AbortSignal]',
|
||||
);
|
||||
@@ -267,6 +271,8 @@ describe('AbortController', () => {
|
||||
it("should throw a TypeError if 'this' is not an AbortController object", () => {
|
||||
expect(() => {
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
controller.abort.call({});
|
||||
}).toThrow(
|
||||
"Expected 'this' to be an 'AbortController' object, but got object",
|
||||
|
||||
@@ -99,45 +99,65 @@ class TimersTest extends React.Component<Props, State> {
|
||||
|
||||
componentDidMount() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setTimeout(this.testSetTimeout0, 1000);
|
||||
}
|
||||
|
||||
testSetTimeout0() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setTimeout(this.testSetTimeout1, 0);
|
||||
}
|
||||
|
||||
testSetTimeout1() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setTimeout(this.testSetTimeout50, 1);
|
||||
}
|
||||
|
||||
testSetTimeout50() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setTimeout(this.testRequestAnimationFrame, 50);
|
||||
}
|
||||
|
||||
testRequestAnimationFrame() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.requestAnimationFrame(this.testSetInterval0);
|
||||
}
|
||||
|
||||
testSetInterval0() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this._nextTest = this.testSetInterval20;
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this._interval = this.setInterval(this._incrementInterval, 0);
|
||||
}
|
||||
|
||||
testSetInterval20() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this._nextTest = this.testSetImmediate;
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this._interval = this.setInterval(this._incrementInterval, 20);
|
||||
}
|
||||
|
||||
testSetImmediate() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setImmediate(this.testClearTimeout0);
|
||||
}
|
||||
|
||||
@@ -151,6 +171,8 @@ class TimersTest extends React.Component<Props, State> {
|
||||
const timeout = this.setTimeout(() => this._fail('testClearTimeout30'), 30);
|
||||
this.clearTimeout(timeout);
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setTimeout(this.testClearMulti, 50);
|
||||
}
|
||||
|
||||
@@ -169,6 +191,8 @@ class TimersTest extends React.Component<Props, State> {
|
||||
this.setTimeout(() => this.clearTimeout(delayClear), 20);
|
||||
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setTimeout(this.testOrdering, 50);
|
||||
}
|
||||
|
||||
@@ -205,6 +229,8 @@ class TimersTest extends React.Component<Props, State> {
|
||||
25,
|
||||
);
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
this.setTimeout(this.done, 50);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ async function stopMetroServer(metroServer: MetroServer): Promise<void> {
|
||||
|
||||
// $FlowFixMe[method-unbinding] Node 18.2+ API
|
||||
if (typeof metroServer.closeIdleConnections === 'function') {
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
metroServer.closeIdleConnections();
|
||||
}
|
||||
|
||||
@@ -57,6 +59,8 @@ async function stopMetroServer(metroServer: MetroServer): Promise<void> {
|
||||
setTimeout(() => {
|
||||
// $FlowFixMe[method-unbinding] Node 18.2+ API
|
||||
if (typeof metroServer.closeAllConnections === 'function') {
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
metroServer.closeAllConnections();
|
||||
}
|
||||
resolve();
|
||||
|
||||
+10
@@ -580,14 +580,24 @@ class Expect {
|
||||
* will not be added to the prototype.
|
||||
*/
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Expect.prototype.toBeCalled = Expect.prototype.toHaveBeenCalled;
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Expect.prototype.toBeCalledTimes = Expect.prototype.toHaveBeenCalledTimes;
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Expect.prototype.toBeCalledWith = Expect.prototype.toHaveBeenCalledWith;
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Expect.prototype.lastCalledWith = Expect.prototype.toHaveBeenLastCalledWith;
|
||||
// $FlowExpectedError[method-unbinding]
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
Expect.prototype.nthCalledWith = Expect.prototype.toHaveBeenNthCalledWith;
|
||||
|
||||
const expect: unknown => Expect = (received: unknown) => new Expect(received);
|
||||
|
||||
@@ -38,6 +38,8 @@ export default function patchWeakRef(): void {
|
||||
);
|
||||
}
|
||||
|
||||
/* $FlowFixMe[invalid-this-arg] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
return originalDeref.call(this);
|
||||
};
|
||||
|
||||
|
||||
@@ -545,6 +545,8 @@ describe('expect', () => {
|
||||
});
|
||||
|
||||
it('tracks execution of methods with an implementation', () => {
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
const fn = jest.fn(function (this: {prop: number}): number {
|
||||
return this.prop;
|
||||
});
|
||||
@@ -569,6 +571,8 @@ describe('expect', () => {
|
||||
});
|
||||
|
||||
it('tracks constructors with an implementation', () => {
|
||||
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
|
||||
* unsoundness in flow */
|
||||
const fn = jest.fn(function (this: {prop: number}) {
|
||||
this.prop = 3;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user