From 64a898cfb17704de3811b39a5dcde4ff6b2005ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 25 Feb 2025 08:29:23 -0800 Subject: [PATCH] Add SafeAreaView to buildTypes and align Flow with TS types (#49664) Summary: Changelog: [Internal] - Added SafeAreaView to buildTypes and aligned Flow with TS types Reviewed By: huntie Differential Revision: D70176107 --- .../Components/SafeAreaView/SafeAreaView.js | 2 +- .../__snapshots__/public-api-test.js.snap | 2 +- .../types/__typetests__/index.tsx | 26 +++++++++++++++++++ scripts/build/build-types/buildTypes.js | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js index e3da1d7798c42d..290fdbd0e06e6f 100644 --- a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -24,7 +24,7 @@ import * as React from 'react'; * sensor housing area on iPhone X). */ const exported: component( - ref: React.RefSetter>, + ref?: React.RefSetter>, ...props: ViewProps ) = Platform.select({ ios: require('./RCTSafeAreaViewNativeComponent').default, diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index ff4788e611810e..2dfd98b3f5ed0a 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -1795,7 +1795,7 @@ declare export default typeof RCTSafeAreaViewNativeComponent; exports[`public API should not change unintentionally Libraries/Components/SafeAreaView/SafeAreaView.js 1`] = ` "declare const exported: component( - ref: React.RefSetter>, + ref?: React.RefSetter>, ...props: ViewProps ); declare export default typeof exported; diff --git a/packages/react-native/types/__typetests__/index.tsx b/packages/react-native/types/__typetests__/index.tsx index a089ae8e1b186c..d0b70cd98fcb1d 100644 --- a/packages/react-native/types/__typetests__/index.tsx +++ b/packages/react-native/types/__typetests__/index.tsx @@ -110,6 +110,7 @@ import { UIManager, View, ViewStyle, + SafeAreaView, VirtualizedList, findNodeHandle, requireNativeComponent, @@ -1568,6 +1569,31 @@ class BridgedComponentTest extends React.Component { } } +const SafeAreaViewTest = () => { + const viewRef = React.createRef>(); + + return ( + <> + ; + ; + { + ref?.focus(); + ref?.blur(); + ref?.measure( + (x, y, width, height, pageX, pageY): number => + x + y + width + height + pageX + pageY, + ); + ref?.measureInWindow( + (x, y, width, height): number => x + y + width + height, + ); + ref?.setNativeProps({focusable: false}); + }} + /> + + ); +}; + const SwitchRefTest = () => { const switchRef = React.createRef>(); diff --git a/scripts/build/build-types/buildTypes.js b/scripts/build/build-types/buildTypes.js index 411416478f7d4a..ca087e36014081 100644 --- a/scripts/build/build-types/buildTypes.js +++ b/scripts/build/build-types/buildTypes.js @@ -80,6 +80,7 @@ const ENTRY_POINTS = [ 'packages/react-native/Libraries/Components/Switch/Switch.js', 'packages/react-native/Libraries/Components/StatusBar/StatusBar.js', 'packages/react-native/Libraries/Components/RefreshControl/RefreshControl.js', + 'packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js', ]; /**