Skip to content

Commit 477c3b6

Browse files
rubennortegabrieldonadel
authored andcommitted
Refactor IntersectionObserver, MutationObserver and PerformanceObserver options as interfaces (facebook#49737)
Summary: Pull Request resolved: facebook#49737 Changelog: [internal] Just a minor change to align with similar other option bags and TypeScript definitions. Reviewed By: huntie Differential Revision: D70355669 fbshipit-source-id: 37c44338c7b358eb2d25e8a14c75a78545b34bf1
1 parent dc20d68 commit 477c3b6

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9460,10 +9460,10 @@ exports[`public API should not change unintentionally src/private/webapis/inters
94609460
entries: Array<IntersectionObserverEntry>,
94619461
observer: IntersectionObserver
94629462
) => mixed;
9463-
type IntersectionObserverInit = {
9464-
threshold?: number | $ReadOnlyArray<number>,
9465-
rnRootThreshold?: number | $ReadOnlyArray<number>,
9466-
};
9463+
export interface IntersectionObserverInit {
9464+
threshold?: number | $ReadOnlyArray<number>;
9465+
rnRootThreshold?: number | $ReadOnlyArray<number>;
9466+
}
94679467
declare export default class IntersectionObserver {
94689468
constructor(
94699469
callback: IntersectionObserverCallback,
@@ -9507,15 +9507,15 @@ exports[`public API should not change unintentionally src/private/webapis/mutati
95079507
mutationRecords: $ReadOnlyArray<MutationRecord>,
95089508
observer: MutationObserver
95099509
) => mixed;
9510-
type MutationObserverInit = $ReadOnly<{
9511-
subtree?: boolean,
9512-
childList: true,
9513-
attributes?: boolean,
9514-
attributeFilter?: $ReadOnlyArray<string>,
9515-
attributeOldValue?: boolean,
9516-
characterData?: boolean,
9517-
characterDataOldValue?: boolean,
9518-
}>;
9510+
export interface MutationObserverInit {
9511+
+subtree?: boolean;
9512+
+childList: true;
9513+
+attributes?: boolean;
9514+
+attributeFilter?: $ReadOnlyArray<string>;
9515+
+attributeOldValue?: boolean;
9516+
+characterData?: boolean;
9517+
+characterDataOldValue?: boolean;
9518+
}
95199519
declare export default class MutationObserver {
95209520
constructor(callback: MutationObserverCallback): void;
95219521
observe(target: ReactNativeElement, options?: MutationObserverInit): void;
@@ -9687,12 +9687,12 @@ export type PerformanceObserverCallback = (
96879687
observer: PerformanceObserver,
96889688
options?: PerformanceObserverCallbackOptions
96899689
) => void;
9690-
export type PerformanceObserverInit = {
9691-
entryTypes?: Array<PerformanceEntryType>,
9692-
type?: PerformanceEntryType,
9693-
buffered?: boolean,
9694-
durationThreshold?: DOMHighResTimeStamp,
9695-
};
9690+
export interface PerformanceObserverInit {
9691+
+entryTypes?: Array<PerformanceEntryType>;
9692+
+type?: PerformanceEntryType;
9693+
+buffered?: boolean;
9694+
+durationThreshold?: DOMHighResTimeStamp;
9695+
}
96969696
declare export class PerformanceObserver {
96979697
constructor(callback: PerformanceObserverCallback): void;
96989698
observe(options: PerformanceObserverInit): void;

packages/react-native/src/private/webapis/intersectionobserver/IntersectionObserver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export type IntersectionObserverCallback = (
2121
observer: IntersectionObserver,
2222
) => mixed;
2323

24-
type IntersectionObserverInit = {
24+
export interface IntersectionObserverInit {
2525
// root?: ReactNativeElement, // This option exists on the Web but it's not currently supported in React Native.
2626
// rootMargin?: string, // This option exists on the Web but it's not currently supported in React Native.
27-
threshold?: number | $ReadOnlyArray<number>,
27+
threshold?: number | $ReadOnlyArray<number>;
2828

2929
/**
3030
* This is a React Native specific option (not spec compliant) that specifies
@@ -36,8 +36,8 @@ type IntersectionObserverInit = {
3636
* Note: If `rnRootThreshold` is set, and `threshold` is not set,
3737
* `threshold` will not default to [0] (as per spec)
3838
*/
39-
rnRootThreshold?: number | $ReadOnlyArray<number>,
40-
};
39+
rnRootThreshold?: number | $ReadOnlyArray<number>;
40+
}
4141

4242
/**
4343
* The [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ export type MutationObserverCallback = (
2121
observer: MutationObserver,
2222
) => mixed;
2323

24-
type MutationObserverInit = $ReadOnly<{
25-
subtree?: boolean,
24+
export interface MutationObserverInit {
25+
+subtree?: boolean;
2626
// This is the only supported option so it's required to be `true`.
27-
childList: true,
27+
+childList: true;
2828

2929
// Unsupported:
30-
attributes?: boolean,
31-
attributeFilter?: $ReadOnlyArray<string>,
32-
attributeOldValue?: boolean,
33-
characterData?: boolean,
34-
characterDataOldValue?: boolean,
35-
}>;
30+
+attributes?: boolean;
31+
+attributeFilter?: $ReadOnlyArray<string>;
32+
+attributeOldValue?: boolean;
33+
+characterData?: boolean;
34+
+characterDataOldValue?: boolean;
35+
}
3636

3737
/**
3838
* This is a React Native implementation for the `MutationObserver` API

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export type PerformanceObserverCallback = (
6666
options?: PerformanceObserverCallbackOptions,
6767
) => void;
6868

69-
export type PerformanceObserverInit = {
70-
entryTypes?: Array<PerformanceEntryType>,
71-
type?: PerformanceEntryType,
72-
buffered?: boolean,
73-
durationThreshold?: DOMHighResTimeStamp,
74-
};
69+
export interface PerformanceObserverInit {
70+
+entryTypes?: Array<PerformanceEntryType>;
71+
+type?: PerformanceEntryType;
72+
+buffered?: boolean;
73+
+durationThreshold?: DOMHighResTimeStamp;
74+
}
7575

7676
function getSupportedPerformanceEntryTypes(): $ReadOnlyArray<PerformanceEntryType> {
7777
if (!NativePerformance) {

0 commit comments

Comments
 (0)