From 7df50d2be5b32a1c72d49c3c83d4014ac3eec6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bert?= Date: Fri, 1 Mar 2024 13:37:18 +0100 Subject: [PATCH 1/2] Move customDirectEventTypes to seperate files --- src/handlers/createHandler.tsx | 3 +-- src/handlers/customDirectEventTypes.ts | 8 ++++++++ src/handlers/customDirectEventTypes.web.ts | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/handlers/customDirectEventTypes.ts create mode 100644 src/handlers/customDirectEventTypes.web.ts diff --git a/src/handlers/createHandler.tsx b/src/handlers/createHandler.tsx index d33adefb43..6829550998 100644 --- a/src/handlers/createHandler.tsx +++ b/src/handlers/createHandler.tsx @@ -5,8 +5,7 @@ import { DeviceEventEmitter, EmitterSubscription, } from 'react-native'; -// @ts-ignore - its taken straight from RN -import { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry'; +import customDirectEventTypes from './customDirectEventTypes'; // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types import deepEqual from 'lodash/isEqual'; import RNGestureHandlerModule from '../RNGestureHandlerModule'; diff --git a/src/handlers/customDirectEventTypes.ts b/src/handlers/customDirectEventTypes.ts new file mode 100644 index 0000000000..5dc8ba136d --- /dev/null +++ b/src/handlers/customDirectEventTypes.ts @@ -0,0 +1,8 @@ +// @ts-ignore - its taken straight from RN +import { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry'; + +customDirectEventTypes.topGestureHandlerEvent = { + registrationName: 'onGestureHandlerEvent', +}; + +export default customDirectEventTypes; diff --git a/src/handlers/customDirectEventTypes.web.ts b/src/handlers/customDirectEventTypes.web.ts new file mode 100644 index 0000000000..8379168057 --- /dev/null +++ b/src/handlers/customDirectEventTypes.web.ts @@ -0,0 +1,3 @@ +// customDirectEventTypes doesn't exist in react-native-web, therefore importing it +// directly in createHandler.tsx would end in crash. +export default {}; From ec91d333797ff1af7eb785f1fd6030ff774c9120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bert?= Date: Fri, 1 Mar 2024 14:53:42 +0100 Subject: [PATCH 2/2] Remove overriding in .ts file --- src/handlers/createHandler.tsx | 2 +- src/handlers/customDirectEventTypes.ts | 8 +------- src/handlers/customDirectEventTypes.web.ts | 4 +++- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/handlers/createHandler.tsx b/src/handlers/createHandler.tsx index 6829550998..a7e74ca5f5 100644 --- a/src/handlers/createHandler.tsx +++ b/src/handlers/createHandler.tsx @@ -5,7 +5,7 @@ import { DeviceEventEmitter, EmitterSubscription, } from 'react-native'; -import customDirectEventTypes from './customDirectEventTypes'; +import { customDirectEventTypes } from './customDirectEventTypes'; // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types import deepEqual from 'lodash/isEqual'; import RNGestureHandlerModule from '../RNGestureHandlerModule'; diff --git a/src/handlers/customDirectEventTypes.ts b/src/handlers/customDirectEventTypes.ts index 5dc8ba136d..3848dac64c 100644 --- a/src/handlers/customDirectEventTypes.ts +++ b/src/handlers/customDirectEventTypes.ts @@ -1,8 +1,2 @@ // @ts-ignore - its taken straight from RN -import { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry'; - -customDirectEventTypes.topGestureHandlerEvent = { - registrationName: 'onGestureHandlerEvent', -}; - -export default customDirectEventTypes; +export { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry'; diff --git a/src/handlers/customDirectEventTypes.web.ts b/src/handlers/customDirectEventTypes.web.ts index 8379168057..b7867a663b 100644 --- a/src/handlers/customDirectEventTypes.web.ts +++ b/src/handlers/customDirectEventTypes.web.ts @@ -1,3 +1,5 @@ // customDirectEventTypes doesn't exist in react-native-web, therefore importing it // directly in createHandler.tsx would end in crash. -export default {}; +const customDirectEventTypes = {}; + +export { customDirectEventTypes };