From bc16bc5b01c50fcfedbc3d32eed5591d9dd7cfce Mon Sep 17 00:00:00 2001 From: Dimitar Nestorov Date: Thu, 19 Oct 2023 10:13:07 -0700 Subject: [PATCH] Add `number | null` to `ViewProps['hitSlop']` TypeScript type (#41070) Summary: Setting the `hitSlop` of a `View` to be a `number` didn't work. The Flow type already allows `number`: https://github.com/facebook/react-native/blob/6e42c98aa3423cfbc389e4fe877b5c6b559c8a81/packages/react-native/Libraries/Components/View/ViewPropTypes.js#L618 I updated it to match the [`TouchableWithoutFeedbackProps['hitSlop']`](https://github.com/facebook/react-native/blob/6e42c98aa3423cfbc389e4fe877b5c6b559c8a81/packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts#L72) and [`PressableProps['hitSlop']`](https://github.com/facebook/react-native/blob/6e42c98aa3423cfbc389e4fe877b5c6b559c8a81/packages/react-native/Libraries/Components/Pressable/Pressable.d.ts#L126) types. ## Changelog: [GENERAL] [FIXED] Add `number | null` to `ViewProps['hitSlop']` TypeScript type Pull Request resolved: https://github.com/facebook/react-native/pull/41070 Test Plan: Ran `yarn test-typescript` and `yarn test-typescript-offline` and there were no errors. Reviewed By: rshest Differential Revision: D50451318 Pulled By: javache fbshipit-source-id: a0fceba270dbb80383cceb16f7719252a05b62b5 --- .../react-native/Libraries/Components/View/ViewPropTypes.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Components/View/ViewPropTypes.d.ts b/packages/react-native/Libraries/Components/View/ViewPropTypes.d.ts index 53f5e82c341..8c67a32ec90 100644 --- a/packages/react-native/Libraries/Components/View/ViewPropTypes.d.ts +++ b/packages/react-native/Libraries/Components/View/ViewPropTypes.d.ts @@ -184,7 +184,7 @@ export interface ViewProps * the Z-index of sibling views always takes precedence if a touch * hits two overlapping views. */ - hitSlop?: Insets | undefined; + hitSlop?: null | Insets | number | undefined; /** * Used to reference react managed views from native code.