Skip to content

Commit 84a1211

Browse files
rubennortefacebook-github-bot
authored andcommitted
Strip all "bom" types that are actually not defined in RN (facebook#49730)
Summary: Pull Request resolved: facebook#49730 Changelog: [internal] This removes all the types from "bom" that are actually not implemented in RN. For now, we're just stripping whole interfaces and not looking into specific methods/properties in interfaces that we do implement but not 100%. `Performance`, `PerformanceObserver`, `MutationObserver` and `IntersectionObserver` are implemented but not stable yet, so they aren't exposed as globals in the types. Reviewed By: huntie Differential Revision: D70329185 fbshipit-source-id: 63bac619e100ca66b41df071df80dfa73d0f9651
1 parent 52713ee commit 84a1211

18 files changed

+180
-2490
lines changed

packages/react-native/Libraries/Core/setUpReactDevTools.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ if (__DEV__) {
152152
// Read the optional global variable for backward compatibility.
153153
// It was added in https://github.com/facebook/react-native/commit/bf2b435322e89d0aeee8792b1c6e04656c2719a0.
154154
const port =
155+
// $FlowFixMe[prop-missing]
155156
// $FlowFixMe[incompatible-use]
156157
window.__REACT_DEVTOOLS_PORT__ != null
157158
? window.__REACT_DEVTOOLS_PORT__

packages/react-native/Libraries/Network/XMLHttpRequest_new.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
EventCallback,
1515
EventListener,
1616
} from '../../src/private/webapis/dom/events/EventTarget';
17+
import type Performance from '../../src/private/webapis/performance/Performance';
1718
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
1819

1920
import Event from '../../src/private/webapis/dom/events/Event';
@@ -33,6 +34,8 @@ const RCTNetworking = require('./RCTNetworking').default;
3334
const base64 = require('base64-js');
3435
const invariant = require('invariant');
3536

37+
declare var performance: Performance;
38+
3639
const DEBUG_NETWORK_SEND_DELAY: false = false; // Set to a number of milliseconds when debugging
3740
const LABEL_FOR_MISSING_URL_FOR_PROFILING = 'Unknown URL';
3841

packages/react-native/Libraries/Network/XMLHttpRequest_old.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
'use strict';
1212

13+
import type Performance from '../../src/private/webapis/performance/Performance';
1314
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
1415

1516
import {type EventSubscription} from '../vendor/emitter/EventEmitter';
@@ -22,6 +23,8 @@ const RCTNetworking = require('./RCTNetworking').default;
2223
const base64 = require('base64-js');
2324
const invariant = require('invariant');
2425

26+
declare var performance: Performance;
27+
2528
const DEBUG_NETWORK_SEND_DELAY: false = false; // Set to a number of milliseconds when debugging
2629
const LABEL_FOR_MISSING_URL_FOR_PROFILING = 'Unknown URL';
2730

packages/react-native/flow/Position.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/react-native/src/private/webapis/mutationobserver/__tests__/MutationObserver-itest.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
import type MutationObserverType from '../MutationObserver';
13+
import type MutationRecordType from '../MutationRecord';
1314

1415
import View from '../../../../../Libraries/Components/View/View';
1516
import setUpMutationObserver from '../../../setup/setUpMutationObserver';
@@ -22,6 +23,7 @@ import * as React from 'react';
2223
import '../../../../../Libraries/Core/InitializeCore.js';
2324

2425
declare const MutationObserver: Class<MutationObserverType>;
26+
declare const MutationRecord: Class<MutationRecordType>;
2527

2628
setUpMutationObserver();
2729

packages/react-native/src/private/webapis/performance/__tests__/LongTaskAPI-itest.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
* @fantom_flags enableLongTaskAPI:true
1111
*/
1212

13-
import type {PerformanceObserverCallbackOptions} from '../PerformanceObserver';
13+
import type {
14+
PerformanceObserverCallbackOptions,
15+
PerformanceObserverEntryList,
16+
} from '../PerformanceObserver';
1417

1518
import setUpPerformanceObserver from '../../../setup/setUpPerformanceObserver';
1619
import {PerformanceLongTaskTiming} from '../LongTasks';
20+
import {PerformanceObserver} from '../PerformanceObserver';
1721
import Fantom from '@react-native/fantom';
1822
import nullthrows from 'nullthrows';
1923

packages/react-native/src/private/webapis/performance/__tests__/Performance-benchmark-itest.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212

1313
import '../../../../../Libraries/Core/InitializeCore.js';
1414

15+
import type Performance from '../Performance';
16+
1517
import Fantom from '@react-native/fantom';
1618

19+
declare var performance: Performance;
20+
1721
const clearMarksAndMeasures = () => {
1822
performance.clearMarks();
1923
performance.clearMeasures();
@@ -76,7 +80,9 @@ Fantom.unstable_benchmark
7680
performance.clearMarks('mark');
7781
},
7882
{
79-
beforeEach: () => performance.mark('mark'),
83+
beforeEach: () => {
84+
performance.mark('mark');
85+
},
8086
},
8187
)
8288
.test(
@@ -85,11 +91,12 @@ Fantom.unstable_benchmark
8591
performance.clearMeasures('measure');
8692
},
8793
{
88-
beforeEach: () =>
94+
beforeEach: () => {
8995
performance.measure('measure', {
9096
start: 100,
9197
end: 300,
92-
}),
98+
});
99+
},
93100
},
94101
)
95102
.test('mark + clearMarks', () => {

packages/react-native/src/private/webapis/performance/__tests__/Performance-test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,26 @@
1010
*/
1111

1212
// eslint-disable-next-line lint/sort-imports
13+
import type Performance from '../Performance';
1314
import {performanceEntryTypeToRaw} from '../internals/RawPerformanceEntry';
1415
import {reportEntry} from '../specs/__mocks__/NativePerformanceMock';
1516

1617
jest.mock('../specs/NativePerformance', () =>
1718
require('../specs/__mocks__/NativePerformanceMock'),
1819
);
1920

21+
declare var performance: Performance;
22+
2023
const NativePerformanceMock =
2124
require('../specs/__mocks__/NativePerformanceMock').default;
2225

2326
describe('Performance', () => {
2427
beforeEach(() => {
2528
jest.resetModules();
2629

27-
const Performance = require('../Performance').default;
30+
const PerformanceClass = require('../Performance').default;
2831
// $FlowExpectedError[cannot-write]
29-
global.performance = new Performance();
32+
global.performance = new PerformanceClass();
3033
});
3134

3235
it('reports marks and measures', () => {

packages/react-native/src/private/webapis/performance/__tests__/PerformanceObserver-test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,26 @@
99
* @oncall react_native
1010
*/
1111

12+
import type Performance from '../Performance';
13+
import type {PerformanceEntryList} from '../PerformanceEntry';
14+
1215
jest.mock(
1316
'../specs/NativePerformance',
1417
() => require('../specs/__mocks__/NativePerformanceMock').default,
1518
);
1619

20+
declare var performance: Performance;
21+
1722
describe('PerformanceObserver', () => {
23+
let PerformanceObserver;
24+
1825
beforeEach(() => {
1926
jest.resetModules();
2027

2128
const Performance = require('../Performance').default;
2229
// $FlowExpectedError[cannot-write]
2330
global.performance = new Performance();
24-
global.PerformanceObserver =
25-
require('../PerformanceObserver').PerformanceObserver;
31+
PerformanceObserver = require('../PerformanceObserver').PerformanceObserver;
2632
});
2733

2834
it('prevents durationThreshold to be used together with entryTypes', async () => {

packages/react-native/src/private/webapis/performance/__tests__/UserTimingAPI-itest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@
1010
* @fantom_flags enableLongTaskAPI:true
1111
*/
1212

13+
import type Performance from '../Performance';
14+
1315
import setUpPerformanceObserver from '../../../setup/setUpPerformanceObserver';
1416
import ensureInstance from '../../../utilities/ensureInstance';
17+
import {PerformanceObserver} from '../PerformanceObserver';
1518
import {PerformanceMark} from '../UserTiming';
1619
import Fantom from '@react-native/fantom';
1720

1821
import '../../../../../Libraries/Core/InitializeCore.js';
1922

2023
setUpPerformanceObserver();
2124

25+
declare var performance: Performance;
26+
2227
describe('User Timing API', () => {
2328
describe('performance.mark()', () => {
2429
it('reports marks to observers', () => {

0 commit comments

Comments
 (0)