Skip to content

Commit fc1f2de

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Replace legacy compat types with their new names in TS based lib.dom.d.ts in xplat: 2/n
Summary: X-link: react/metro#1960 Changelog: [Internal] Reviewed By: gkz Differential Revision: D121075922
1 parent 4ffc4a6 commit fc1f2de

18 files changed

Lines changed: 35 additions & 33 deletions

File tree

‎packages/jest-preset/jest/setup.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Object.defineProperties(global, {
2828
cancelAnimationFrame: {
2929
configurable: true,
3030
enumerable: true,
31-
value(id: TimeoutID): void {
31+
value(id: ReturnType<typeof setTimeout>): void {
3232
return clearTimeout(id);
3333
},
3434
writable: true,
@@ -57,7 +57,7 @@ Object.defineProperties(global, {
5757
requestAnimationFrame: {
5858
configurable: true,
5959
enumerable: true,
60-
value(callback: number => void): TimeoutID {
60+
value(callback: number => void): ReturnType<typeof setTimeout> {
6161
return setTimeout(() => callback(jest.now()), 0);
6262
},
6363
writable: true,

‎packages/react-native/Libraries/Animated/animations/SpringAnimation.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default class SpringAnimation extends Animation {
9999
_mass: number;
100100
_initialVelocity: number;
101101
_delay: number;
102-
_timeout: ?TimeoutID;
102+
_timeout: ?ReturnType<typeof setTimeout>;
103103
_startTime: number;
104104
_lastTime: number;
105105
_frameTime: number;

‎packages/react-native/Libraries/Animated/animations/TimingAnimation.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class TimingAnimation extends Animation {
6969
_easing: (value: number) => number;
7070
_onUpdate: (value: number) => void;
7171
_animationFrame: ?number;
72-
_timeout: ?TimeoutID;
72+
_timeout: ?ReturnType<typeof setTimeout>;
7373
_platformConfig: ?PlatformConfig;
7474
_deferredStart: boolean;
7575

‎packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const ScrollViewStickyHeader: component(
119119
);
120120

121121
const haveReceivedInitialZeroTranslateY = useRef<boolean>(true);
122-
const translateYDebounceTimer = useRef<?TimeoutID>(null);
122+
const translateYDebounceTimer = useRef<?ReturnType<typeof setTimeout>>(null);
123123

124124
useEffect(() => {
125125
if (translateY !== 0 && translateY != null) {

‎packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class TouchableHighlightImpl extends React.Component<
9393
TouchableHighlightProps,
9494
TouchableHighlightState,
9595
> {
96-
_hideTimeout: ?TimeoutID;
96+
_hideTimeout: ?ReturnType<typeof setTimeout>;
9797
_isMounted: boolean = false;
9898

9999
state: TouchableHighlightState = {

‎packages/react-native/Libraries/LogBox/Data/LogBoxData.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ export function withSubscription(
476476
}
477477

478478
_subscription: ?Subscription;
479-
_updateStateOnMountTimeoutId: ?TimeoutID;
479+
_updateStateOnMountTimeoutId: ?ReturnType<typeof setTimeout>;
480480

481481
state: LogBoxStateSubscriptionState = {
482482
hasError: false,

‎packages/react-native/Libraries/Pressability/Pressability.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,12 @@ let longPressDeactivationDistance = DEFAULT_LONG_PRESS_DEACTIVATION_DISTANCE;
371371
export default class Pressability {
372372
_config: PressabilityConfig;
373373
_eventHandlers: ?EventHandlers = null;
374-
_hoverInDelayTimeout: ?TimeoutID = null;
375-
_hoverOutDelayTimeout: ?TimeoutID = null;
374+
_hoverInDelayTimeout: ?ReturnType<typeof setTimeout> = null;
375+
_hoverOutDelayTimeout: ?ReturnType<typeof setTimeout> = null;
376376
_isHovered: boolean = false;
377-
_longPressDelayTimeout: ?TimeoutID = null;
378-
_pressDelayTimeout: ?TimeoutID = null;
379-
_pressOutDelayTimeout: ?TimeoutID = null;
377+
_longPressDelayTimeout: ?ReturnType<typeof setTimeout> = null;
378+
_pressDelayTimeout: ?ReturnType<typeof setTimeout> = null;
379+
_pressOutDelayTimeout: ?ReturnType<typeof setTimeout> = null;
380380
_responderID: ?number | HostInstance = null;
381381
_responderRegion: ?Readonly<{
382382
bottom: number,

‎packages/react-native/src/private/animated/createAnimatedPropsHook.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function createAnimatedPropsHook(
5656
): [ReducedProps<TProps>, React.RefCallback<TInstance>] {
5757
const [, scheduleUpdate] = useReducer<number, void>(count => count + 1, 0);
5858
const onUpdateRef = useRef<UpdateCallback | null>(null);
59-
const timerRef = useRef<TimeoutID | null>(null);
59+
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
6060

6161
const rootTag = useContext(RootTagContext);
6262

‎packages/rn-tester/IntegrationTests/TimersTest.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ type ImmediateID = Object;
2727

2828
class TimersTest extends React.Component<Props, State> {
2929
_nextTest = () => {};
30-
_interval: ?IntervalID = null;
30+
_interval: ?ReturnType<typeof setInterval> = null;
3131

32-
_timeoutIDs: Set<TimeoutID> = new Set();
33-
_intervalIDs: Set<IntervalID> = new Set();
32+
_timeoutIDs: Set<ReturnType<typeof setTimeout>> = new Set();
33+
_intervalIDs: Set<ReturnType<typeof setInterval>> = new Set();
3434
_immediateIDs: Set<ImmediateID> = new Set();
3535
_animationFrameIDs: Set<number> = new Set();
3636

@@ -39,8 +39,8 @@ class TimersTest extends React.Component<Props, State> {
3939
done: false,
4040
};
4141

42-
setTimeout(fn: () => void, time: number): TimeoutID {
43-
const id: TimeoutID = setTimeout(() => {
42+
setTimeout(fn: () => void, time: number): ReturnType<typeof setTimeout> {
43+
const id: ReturnType<typeof setTimeout> = setTimeout(() => {
4444
this._timeoutIDs.delete(id);
4545
fn();
4646
}, time);
@@ -50,12 +50,12 @@ class TimersTest extends React.Component<Props, State> {
5050
return id;
5151
}
5252

53-
clearTimeout(id: TimeoutID) {
53+
clearTimeout(id: ReturnType<typeof setTimeout>) {
5454
this._timeoutIDs.delete(id);
5555
clearTimeout(id);
5656
}
5757

58-
setInterval(fn: () => void, time: number): IntervalID {
58+
setInterval(fn: () => void, time: number): ReturnType<typeof setInterval> {
5959
const id = setInterval(() => {
6060
fn();
6161
}, time);
@@ -65,7 +65,7 @@ class TimersTest extends React.Component<Props, State> {
6565
return id;
6666
}
6767

68-
clearInterval(id: IntervalID) {
68+
clearInterval(id: ReturnType<typeof setInterval>) {
6969
this._intervalIDs.delete(id);
7070
clearInterval(id);
7171
}

‎packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,13 +1251,13 @@ class FakeSliderExampleForAccessibilityValue extends React.Component<
12511251
}
12521252

12531253
class AnnounceForAccessibility extends React.Component<{}> {
1254-
_handleOnPress = (): TimeoutID =>
1254+
_handleOnPress = (): ReturnType<typeof setTimeout> =>
12551255
setTimeout(
12561256
() => AccessibilityInfo.announceForAccessibility('Announcement Test'),
12571257
1000,
12581258
);
12591259

1260-
_handleOnPressQueued = (): TimeoutID =>
1260+
_handleOnPressQueued = (): ReturnType<typeof setTimeout> =>
12611261
setTimeout(
12621262
() =>
12631263
AccessibilityInfo.announceForAccessibilityWithOptions(

0 commit comments

Comments
 (0)