From 452bf0ff069b77fc880c57fcb86dbe44ac7285fc Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 4 Oct 2023 06:42:17 -0700 Subject: [PATCH] Remove `` import in `RCTConvert.h` (#39794) Summary: This PR is in response to https://github.com/facebook/react-native/pull/39758#discussion_r1344839022 . `RCTConvert.h` currently takes an import of `` for... one enum: `WKDataDetectorTypes`. This has a few problems: 1) RCTConvert is JS engine agnostic, it shouldn't be depending on Webkit 2) As far as I can tell, this code is dead, we also define (and use) the UIKit equivalent `UIDataDetectorTypes`. Let's just combine the two, update some JS typing, and get rid of the Webkit header import. ## Changelog: [IOS] [CHANGED] - Remove `` import in `RCTConvert.h` Pull Request resolved: https://github.com/facebook/react-native/pull/39794 Test Plan: CI should pass Reviewed By: rshest Differential Revision: D49898701 Pulled By: NickGerleman fbshipit-source-id: 5420cb62317e1186426aae019bcc43d27c49ea26 --- .../Components/TextInput/TextInput.d.ts | 3 +++ .../Components/TextInput/TextInput.flow.js | 3 +++ .../Components/TextInput/TextInput.js | 3 +++ packages/react-native/React/Base/RCTConvert.h | 7 ------- packages/react-native/React/Base/RCTConvert.m | 19 +++---------------- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts index fa196a19491df0..80db8f0a652225 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts @@ -84,6 +84,9 @@ type DataDetectorTypes = | 'link' | 'address' | 'calendarEvent' + | 'trackingNumber' + | 'flightNumber' + | 'lookupSuggestion' | 'none' | 'all'; diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js index 39ba481b7e4751..0eb8f578d65879 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js @@ -99,6 +99,9 @@ type DataDetectorTypesType = | 'link' | 'address' | 'calendarEvent' + | 'trackingNumber' + | 'flightNumber' + | 'lookupSuggestion' | 'none' | 'all'; diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index 2dddd7ae6bff38..f0416dce6c603a 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -137,6 +137,9 @@ type DataDetectorTypesType = | 'link' | 'address' | 'calendarEvent' + | 'trackingNumber' + | 'flightNumber' + | 'lookupSuggestion' | 'none' | 'all'; diff --git a/packages/react-native/React/Base/RCTConvert.h b/packages/react-native/React/Base/RCTConvert.h index 5b4559d94b1224..7a6ca764191d0d 100644 --- a/packages/react-native/React/Base/RCTConvert.h +++ b/packages/react-native/React/Base/RCTConvert.h @@ -16,9 +16,6 @@ #import #import #import -#if TARGET_OS_IPHONE -#import -#endif /** * This class provides a collection of conversion functions for mapping @@ -78,10 +75,6 @@ typedef NSURL RCTFileURL; + (UIDataDetectorTypes)UIDataDetectorTypes:(id)json; #endif -#if TARGET_OS_IPHONE -+ (WKDataDetectorTypes)WKDataDetectorTypes:(id)json; -#endif - + (UIViewContentMode)UIViewContentMode:(id)json; #if !TARGET_OS_TV + (UIBarStyle)UIBarStyle:(id)json; diff --git a/packages/react-native/React/Base/RCTConvert.m b/packages/react-native/React/Base/RCTConvert.m index 3a7d2b4fc35d00..34822463593f8f 100644 --- a/packages/react-native/React/Base/RCTConvert.m +++ b/packages/react-native/React/Base/RCTConvert.m @@ -450,28 +450,15 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC @"link" : @(UIDataDetectorTypeLink), @"address" : @(UIDataDetectorTypeAddress), @"calendarEvent" : @(UIDataDetectorTypeCalendarEvent), + @"trackingNumber" : @(UIDataDetectorTypeShipmentTrackingNumber), + @"flightNumber" : @(UIDataDetectorTypeFlightNumber), + @"lookupSuggestion" : @(UIDataDetectorTypeLookupSuggestion), @"none" : @(UIDataDetectorTypeNone), @"all" : @(UIDataDetectorTypeAll), }), UIDataDetectorTypePhoneNumber, unsignedLongLongValue) -RCT_MULTI_ENUM_CONVERTER( - WKDataDetectorTypes, - (@{ - @"phoneNumber" : @(WKDataDetectorTypePhoneNumber), - @"link" : @(WKDataDetectorTypeLink), - @"address" : @(WKDataDetectorTypeAddress), - @"calendarEvent" : @(WKDataDetectorTypeCalendarEvent), - @"trackingNumber" : @(WKDataDetectorTypeTrackingNumber), - @"flightNumber" : @(WKDataDetectorTypeFlightNumber), - @"lookupSuggestion" : @(WKDataDetectorTypeLookupSuggestion), - @"none" : @(WKDataDetectorTypeNone), - @"all" : @(WKDataDetectorTypeAll), - }), - WKDataDetectorTypePhoneNumber, - unsignedLongLongValue) - RCT_ENUM_CONVERTER( UIKeyboardAppearance, (@{