From c24c8a039c4a63a9c72de8c343450b31c874145f Mon Sep 17 00:00:00 2001 From: Eli White Date: Thu, 5 Dec 2019 13:31:43 -0800 Subject: [PATCH] Core files should depend on internals directly Summary: By depending on react-native, these files can't be flow strict until index.js is flow strict. By depending on the internals directly they can be flow strict as soon as their dependents are flow strict. Changelog: [Internal] Refactoring some core file imports to depend on internals directly Reviewed By: zackargyle Differential Revision: D18828324 fbshipit-source-id: 2a347c4e234a64edbb3e6f0ef6387ef1ce78badc --- .../Components/Picker/AndroidDialogPickerNativeComponent.js | 4 ++-- .../Picker/AndroidDropdownPickerNativeComponent.js | 4 ++-- .../Components/TextInput/AndroidTextInputNativeComponent.js | 2 +- Libraries/Components/Touchable/TVTouchable.js | 3 ++- Libraries/Components/Touchable/TouchableHighlight.js | 5 +++-- Libraries/Components/Touchable/TouchableNativeFeedback.js | 4 +++- Libraries/Components/Touchable/TouchableOpacity.js | 2 +- Libraries/Components/Touchable/TouchableWithoutFeedback.js | 3 ++- Libraries/LogBox/UI/AnsiHighlight.js | 3 ++- Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js | 3 ++- Libraries/Pressability/HoverState.js | 2 +- Libraries/Pressability/Pressability.js | 4 +++- Libraries/Pressability/PressabilityDebug.js | 3 ++- Libraries/Pressability/__tests__/Pressability-test.js | 3 ++- Libraries/Utilities/codegenNativeComponent.js | 2 +- 15 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js index 574d9773362..5ed854eb381 100644 --- a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js @@ -12,8 +12,8 @@ import * as React from 'react'; -import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands'; -import {requireNativeComponent} from 'react-native'; +import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; +import requireNativeComponent from '../../ReactNative/requireNativeComponent'; import type { DirectEventHandler, diff --git a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js index 7c637ef4e6b..7fc757fc34f 100644 --- a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js @@ -12,8 +12,8 @@ import * as React from 'react'; -import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands'; -import {requireNativeComponent} from 'react-native'; +import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; +import requireNativeComponent from '../../ReactNative/requireNativeComponent'; import type { DirectEventHandler, diff --git a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index 3a381d1bdb6..417b9c7dc61 100644 --- a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -22,7 +22,7 @@ import type { import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type {TextStyleProp, ViewStyleProp} from '../../StyleSheet/StyleSheet'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; -import {requireNativeComponent} from 'react-native'; +import requireNativeComponent from '../../ReactNative/requireNativeComponent'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; import * as React from 'react'; diff --git a/Libraries/Components/Touchable/TVTouchable.js b/Libraries/Components/Touchable/TVTouchable.js index 5bf83f6ca3b..8b827d08108 100644 --- a/Libraries/Components/Touchable/TVTouchable.js +++ b/Libraries/Components/Touchable/TVTouchable.js @@ -17,7 +17,8 @@ import type { FocusEvent, PressEvent, } from '../../Types/CoreEventTypes'; -import {Platform, TVEventHandler} from 'react-native'; +import Platform from '../../Utilities/Platform'; +import TVEventHandler from '../../Components/AppleTV/TVEventHandler'; type TVTouchableConfig = $ReadOnly<{| getDisabled: () => boolean, diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 26e30930a0c..1a2948cd177 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -12,11 +12,12 @@ import Pressability from '../../Pressability/Pressability.js'; import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js'; -import type {ViewStyleProp} from '../../StyleSheet/StyleSheet.js'; +import StyleSheet, {type ViewStyleProp} from '../../StyleSheet/StyleSheet.js'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes.js'; import TVTouchable from './TVTouchable.js'; import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js'; -import {Platform, StyleSheet, View} from 'react-native'; +import Platform from '../../Utilities/Platform'; +import View from '../../Components/View/View'; import * as React from 'react'; type AndroidProps = $ReadOnly<{| diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.js index 4003c97d146..52a3a553b0f 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -17,7 +17,9 @@ import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js'; import {Commands} from 'react-native/Libraries/Components/View/ViewNativeComponent'; import ReactNative from 'react-native/Libraries/Renderer/shims/ReactNative'; import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes'; -import {Platform, View, processColor} from 'react-native'; +import Platform from '../../Utilities/Platform'; +import View from '../../Components/View/View'; +import processColor from '../../StyleSheet/processColor'; import * as React from 'react'; type Props = $ReadOnly<{| diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index bf61e54c2a2..dd70883264f 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -18,7 +18,7 @@ import Animated from 'react-native/Libraries/Animated/src/Animated'; import Easing from 'react-native/Libraries/Animated/src/Easing'; import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle'; -import {Platform} from 'react-native'; +import Platform from '../../Utilities/Platform'; import * as React from 'react'; type TVProps = $ReadOnly<{| diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 58f47e23b65..6684d6cd293 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -27,7 +27,8 @@ import type { LayoutEvent, PressEvent, } from '../../Types/CoreEventTypes'; -import {Platform, View} from 'react-native'; +import Platform from '../../Utilities/Platform'; +import View from '../../Components/View/View'; import * as React from 'react'; type Props = $ReadOnly<{| diff --git a/Libraries/LogBox/UI/AnsiHighlight.js b/Libraries/LogBox/UI/AnsiHighlight.js index 6b9bb50d3ad..616a88ca47a 100644 --- a/Libraries/LogBox/UI/AnsiHighlight.js +++ b/Libraries/LogBox/UI/AnsiHighlight.js @@ -9,7 +9,8 @@ */ import {ansiToJson} from 'anser'; -import {Text, View} from 'react-native'; +import Text from '../../Text/Text'; +import View from '../../Components/View/View'; import * as React from 'react'; import type {TextStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; diff --git a/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js b/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js index ee07a2bbc51..a1e7dc39832 100644 --- a/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +++ b/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js @@ -11,7 +11,8 @@ 'use strict'; import * as React from 'react'; -import {Platform, ScrollView} from 'react-native'; +import Platform from '../../Utilities/Platform'; +import ScrollView from '../../Components/ScrollView/ScrollView'; import StyleSheet from '../../StyleSheet/StyleSheet'; import Text from '../../Text/Text'; import View from '../../Components/View/View'; diff --git a/Libraries/Pressability/HoverState.js b/Libraries/Pressability/HoverState.js index d335fff9601..df15f610993 100644 --- a/Libraries/Pressability/HoverState.js +++ b/Libraries/Pressability/HoverState.js @@ -10,7 +10,7 @@ 'use strict'; -import {Platform} from 'react-native'; +import Platform from '../Utilities/Platform'; let isEnabled = false; diff --git a/Libraries/Pressability/Pressability.js b/Libraries/Pressability/Pressability.js index bd5c0e8ded7..5ff89d9f406 100644 --- a/Libraries/Pressability/Pressability.js +++ b/Libraries/Pressability/Pressability.js @@ -20,7 +20,9 @@ import type { PressEvent, MouseEvent, } from '../Types/CoreEventTypes.js'; -import {type HostComponent, Platform, UIManager} from 'react-native'; +import Platform from '../Utilities/Platform'; +import UIManager from '../ReactNative/UIManager'; +import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; import * as React from 'react'; export type PressabilityConfig = $ReadOnly<{| diff --git a/Libraries/Pressability/PressabilityDebug.js b/Libraries/Pressability/PressabilityDebug.js index 3117125b598..36df2290a73 100644 --- a/Libraries/Pressability/PressabilityDebug.js +++ b/Libraries/Pressability/PressabilityDebug.js @@ -11,7 +11,8 @@ 'use strict'; import normalizeColor from '../StyleSheet/normalizeColor.js'; -import {Touchable, View} from 'react-native'; +import Touchable from '../Components/Touchable/Touchable'; +import View from '../Components/View/View'; import * as React from 'react'; type Props = $ReadOnly<{| diff --git a/Libraries/Pressability/__tests__/Pressability-test.js b/Libraries/Pressability/__tests__/Pressability-test.js index 7d1142f5542..5516fa747b9 100644 --- a/Libraries/Pressability/__tests__/Pressability-test.js +++ b/Libraries/Pressability/__tests__/Pressability-test.js @@ -16,7 +16,8 @@ import * as HoverState from '../HoverState.js'; import Pressability from '../Pressability.js'; import invariant from 'invariant'; import nullthrows from 'nullthrows'; -import {Platform, UIManager} from 'react-native'; +import Platform from '../../Utilities/Platform'; +import UIManager from '../../ReactNative/UIManager'; // TODO: Move this util to a shared location. function getMock, TReturn>( diff --git a/Libraries/Utilities/codegenNativeComponent.js b/Libraries/Utilities/codegenNativeComponent.js index 8e94bb9c2f6..3847be3b4db 100644 --- a/Libraries/Utilities/codegenNativeComponent.js +++ b/Libraries/Utilities/codegenNativeComponent.js @@ -14,7 +14,7 @@ import requireNativeComponent from '../../Libraries/ReactNative/requireNativeComponent'; import type {HostComponent} from '../../Libraries/Renderer/shims/ReactNativeTypes'; -import {UIManager} from 'react-native'; +import UIManager from '../ReactNative/UIManager'; // TODO: import from CodegenSchema once workspaces are enabled type Options = $ReadOnly<{|