Skip to content

Commit

Permalink
Fixup TS Organization (#35169)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #35169

This reorganizes typing structure a bit.

`Utilities.d.ts` was originally added for utilitiy types but I ended up leaving it a grab bag of types that didn't belong to any individual bit of code. Out of what is in it right now, `Insets` was actually public, and seems to have been imported.

We also run into files around the renderer which are [currently overwritten](https://github.com/facebook/react-native/commits/e286da25fc83324363486eb668806aca179f74b3/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts) by the React sync script.

Finally, all of the top-level imports of `Utilities` were auto-generated by VS Code, but fail in real apps. I think this is because our tsconfig sets a baseUrl to allow resolution from the types folder, so the tooling in the RN repo will use that, but it breaks in real apps that don't have that mapping.

This splits all these up into a couple separate directories that are hopefully easier to reason about, and removes `Omit` which has been a builtin type for quite some time (we were actually already using built-in `Omit`).

Changelog:
[General][Fixed] - Fixup TS Organization

Differential Revision: D40932319

fbshipit-source-id: f9148925499401775b3d5217ed0f1d7780a7d55b
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Nov 2, 2022
1 parent 358b7a4 commit a7e5898
Show file tree
Hide file tree
Showing 37 changed files with 578 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type * as React from 'react';
import {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import {HostComponent} from '../../../types/public/ReactNativeTypes';
import {EmitterSubscription} from '../../vendor/emitter/EventEmitter';

type AccessibilityChangeEventName =
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from '../../../types/private/Utilities';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {LayoutChangeEvent} from '../../Types/CoreEventTypes';
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/DatePicker/DatePickerIOS.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from '../../../types/private/Utilities';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ViewProps} from '../View/ViewPropTypes';

export interface DatePickerIOSProps extends ViewProps {
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from '../../../types/private/Utilities';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue} from '../../StyleSheet/StyleSheet';
import {
NativeSyntheticEvent,
Expand Down
3 changes: 2 additions & 1 deletion Libraries/Components/Keyboard/KeyboardAvoidingView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*/

import type * as React from 'react';
import {Constructor, TimerMixin} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {TimerMixin} from '../../../types/private/TimerMixin';
import {StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {ViewProps} from '../View/ViewPropTypes';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Pressable/Pressable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type * as React from 'react';
import {Insets} from 'Utilities';
import {Insets} from '../../../types/public/Insets';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from '../../../types/private/Utilities';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue} from '../../StyleSheet/StyleSheet';
import {ViewProps} from '../View/ViewPropTypes';

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/ProgressViewIOS/ProgressViewIOS.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {ImageURISource} from '../../Image/ImageSource';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue} from '../../StyleSheet/StyleSheet';
import {ViewProps} from '../View/ViewPropTypes';

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/RefreshControl/RefreshControl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from '../../../types/private/Utilities';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue} from '../../StyleSheet/StyleSheet';
import {ViewProps} from '../View/ViewPropTypes';

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/SafeAreaView/SafeAreaView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from 'public/Insets';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ViewProps} from '../View/ViewPropTypes';

/**
Expand Down
3 changes: 2 additions & 1 deletion Libraries/Components/ScrollView/ScrollView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*/

import type * as React from 'react';
import {Constructor, Insets} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {Insets} from '../../../types/public/Insets';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Slider/Slider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {ImageURISource} from '../../Image/ImageSource';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {ViewProps} from '../View/ViewPropTypes';
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Switch/Switch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from 'public/Insets';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {ViewProps} from '../View/ViewPropTypes';
Expand Down
5 changes: 3 additions & 2 deletions Libraries/Components/TextInput/TextInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
*/

import type * as React from 'react';
import {Constructor, TimerMixin} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {TimerMixin} from '../../../types/private/TimerMixin';
import {
HostComponent,
NativeMethods,
} from '../../Renderer/shims/ReactNativeTypes';
} from '../../../types/public/ReactNativeTypes';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {TextStyle} from '../../StyleSheet/StyleSheetTypes';
import {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/Touchable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type * as React from 'react';
import {Insets} from 'Utilities';
import {Insets} from '../../../types/public/Insets';
import {GestureResponderEvent} from '../../Types/CoreEventTypes';

/**
Expand Down
5 changes: 3 additions & 2 deletions Libraries/Components/Touchable/TouchableHighlight.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
*/

import type * as React from 'react';
import {Constructor, TimerMixin} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from '../../../types/private/Utilities';
import {TimerMixin} from '../../../types/private/TimerMixin';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {TouchableMixin} from './Touchable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {ColorValue} from '../../StyleSheet/StyleSheet';
import {TouchableMixin} from './Touchable';

Expand Down
5 changes: 3 additions & 2 deletions Libraries/Components/Touchable/TouchableOpacity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
*/

import type * as React from 'react';
import {Constructor, TimerMixin} from 'Utilities';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {Constructor} from '../../../types/private/Utilities';
import {TimerMixin} from '../../../types/private/TimerMixin';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {TVParallaxProperties} from '../View/ViewPropTypes';
import {TouchableMixin} from './Touchable';
import {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback';
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
*/

import type * as React from 'react';
import {Constructor, Insets, TimerMixin} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {TimerMixin} from '../../../types/private/TimerMixin';
import {Insets} from '../../../types/public/Insets';
import {StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/View/View.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {Constructor} from '../../../types/private/Utilities';
import {ViewProps} from './ViewPropTypes';
import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';

/**
* The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/View/ViewPropTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type * as React from 'react';
import {Insets} from '../../../types/Utilities';
import {GestureResponderHandlers} from '../../Renderer/implementations/ReactNativeRenderer';
import {Insets} from '../../../types/public/Insets';
import {GestureResponderHandlers} from '../../../types/public/ReactNativeRenderer';
import {StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {LayoutChangeEvent, PointerEvents} from '../../Types/CoreEventTypes';
Expand Down
5 changes: 3 additions & 2 deletions Libraries/Image/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
*/

import * as React from 'react';
import {Constructor, Insets} from 'Utilities';
import {Constructor} from '../../types/private/Utilities';
import {AccessibilityProps} from '../Components/View/ViewAccessibility';
import {NativeMethods} from '../Renderer/shims/ReactNativeTypes';
import {Insets} from '../../types/public/Insets';
import {NativeMethods} from '../../types/public/ReactNativeTypes';
import {StyleProp} from '../StyleSheet/StyleSheet';
import {ImageStyle, ViewStyle} from '../StyleSheet/StyleSheetTypes';
import {LayoutChangeEvent, NativeSyntheticEvent} from '../Types/CoreEventTypes';
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Text/Text.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

import type * as React from 'react';
import {Constructor} from 'Utilities';
import {Constructor} from '../../types/private/Utilities';
import {AccessibilityProps} from '../Components/View/ViewAccessibility';
import {NativeMethods} from '../Renderer/shims/ReactNativeTypes';
import {NativeMethods} from '../../types/public/ReactNativeTypes';
import {ColorValue, StyleProp} from '../StyleSheet/StyleSheet';
import {TextStyle} from '../StyleSheet/StyleSheetTypes';
import {
Expand Down
18 changes: 10 additions & 8 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// <reference path="globals.d.ts" />
/// <reference path="legacy-properties.d.ts" />
/// <reference path="BatchedBridge.d.ts" />
/// <reference path="Codegen.d.ts" />
/// <reference path="Devtools.d.ts" />
/// <reference path="LaunchScreen.d.ts" />
/// <reference path="modules/BatchedBridge.d.ts" />
/// <reference path="modules/Codegen.d.ts" />
/// <reference path="modules/Devtools.d.ts" />
/// <reference path="modules/globals.d.ts" />
/// <reference path="modules/LaunchScreen.d.ts" />

export * from '../Libraries/ActionSheetIOS/ActionSheetIOS';
export * from '../Libraries/Alert/Alert';
Expand Down Expand Up @@ -131,8 +130,6 @@ export * from '../Libraries/ReactNative/I18nManager';
export * from '../Libraries/ReactNative/RendererProxy';
export * from '../Libraries/ReactNative/UIManager';
export * from '../Libraries/ReactNative/requireNativeComponent';
export * from '../Libraries/Renderer/implementations/ReactNativeRenderer';
export * from '../Libraries/Renderer/shims/ReactNativeTypes';
export * from '../Libraries/Settings/Settings';
export * from '../Libraries/Share/Share';
export * from '../Libraries/StyleSheet/PlatformColorValueTypesIOS';
Expand All @@ -155,6 +152,11 @@ export * from '../Libraries/YellowBox/YellowBoxDeprecated';
export * from '../Libraries/vendor/core/ErrorUtils';
export * from '../Libraries/vendor/emitter/EventEmitter';

export * from './public/DeprecatedPropertiesAlias';
export * from './public/Insets';
export * from './public/ReactNativeRenderer';
export * from './public/ReactNativeTypes';

import type {ErrorUtils} from '../Libraries/vendor/core/ErrorUtils';

declare global {
Expand Down
Loading

0 comments on commit a7e5898

Please sign in to comment.