From d4d323cbc2469d54bbd684c478953df5bc815421 Mon Sep 17 00:00:00 2001 From: Yupeng Li Date: Tue, 22 Aug 2023 13:54:39 -0700 Subject: [PATCH] Remove deprecated removeSubscription from the type of NativeEventEmitter (#39115) Summary: Removed deprecated function removeSubscription from the type of NativeEventEmitter, so that it lines up with its implementation. This is a fix for https://github.com/facebook/react-native/issues/39111 . ## Changelog: [General] [Fixed] - Fix a type issue of NativeEventEmitter Pull Request resolved: https://github.com/facebook/react-native/pull/39115 Test Plan: Not applicable Reviewed By: NickGerleman Differential Revision: D48573676 Pulled By: lunaleaps fbshipit-source-id: e70c951e230e0d236e0bf0a1ba02b450bdc98ac5 --- .../Libraries/EventEmitter/NativeEventEmitter.d.ts | 6 ------ packages/react-native/types/__typetests__/index.tsx | 2 -- 2 files changed, 8 deletions(-) diff --git a/packages/react-native/Libraries/EventEmitter/NativeEventEmitter.d.ts b/packages/react-native/Libraries/EventEmitter/NativeEventEmitter.d.ts index 911d0a7ca8a7f8..efcacad83c6085 100644 --- a/packages/react-native/Libraries/EventEmitter/NativeEventEmitter.d.ts +++ b/packages/react-native/Libraries/EventEmitter/NativeEventEmitter.d.ts @@ -60,10 +60,4 @@ declare class NativeEventEmitter extends EventEmitter { * @param eventType name of the event whose registered listeners to remove */ removeAllListeners(eventType: string): void; - - /** - * Removes a subscription created by the addListener, the EventSubscription#remove() - * function actually calls through to this. - */ - removeSubscription(subscription: EmitterSubscription): void; } diff --git a/packages/react-native/types/__typetests__/index.tsx b/packages/react-native/types/__typetests__/index.tsx index 9770ef1cf81204..d7382b98b79586 100644 --- a/packages/react-native/types/__typetests__/index.tsx +++ b/packages/react-native/types/__typetests__/index.tsx @@ -1068,7 +1068,6 @@ const sub2 = androidEventEmitter.addListener( androidEventEmitter.listenerCount('event'); // $ExpectType number sub2.remove(); androidEventEmitter.removeAllListeners('event'); -androidEventEmitter.removeSubscription(sub1); // NativeEventEmitter - IOS const nativeModule: NativeModule = { @@ -1081,7 +1080,6 @@ const sub4 = iosEventEmitter.addListener('event', (event: object) => event, {}); iosEventEmitter.listenerCount('event'); sub4.remove(); iosEventEmitter.removeAllListeners('event'); -iosEventEmitter.removeSubscription(sub3); class CustomEventEmitter extends NativeEventEmitter {}