Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native: add deprecation notice for deprecated components/modules #48869

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 72 additions & 13 deletions types/react-native/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,7 @@ export interface TransformsStyle {
| TranslateYTransform
| SkewXTransform
| SkewYTransform
| MatrixTransform
)[];
| MatrixTransform)[];
/**
* @deprecated Use matrix in transform prop instead.
*/
Expand Down Expand Up @@ -967,7 +966,7 @@ export interface TextPropsAndroid {
* Determines the types of data converted to clickable URLs in the text element.
* By default no data types are detected.
*/
dataDetectorType?: null |'phoneNumber' | 'link' | 'email' | 'none' | 'all';
dataDetectorType?: null | 'phoneNumber' | 'link' | 'email' | 'none' | 'all';
}

// https://facebook.github.io/react-native/docs/text.html#props
Expand Down Expand Up @@ -3336,6 +3335,12 @@ export interface ProgressBarAndroidProps extends ViewProps {
*/
declare class ProgressBarAndroidComponent extends React.Component<ProgressBarAndroidProps> {}
declare const ProgressBarAndroidBase: Constructor<NativeMethodsMixinType> & typeof ProgressBarAndroidComponent;
/**
* ProgressBarAndroid has been extracted from react-native core and will be removed in a future release.
* It can now be installed and imported from `@react-native-community/progress-bar-android` instead of 'react-native'.
* @see https://github.com/react-native-progress-view/progress-bar-android
* @deprecated
*/
export class ProgressBarAndroid extends ProgressBarAndroidBase {}

/**
Expand Down Expand Up @@ -3601,14 +3606,21 @@ declare const SliderBase: Constructor<NativeMethodsMixinType> & typeof SliderCom
/**
* Slider has been extracted from react-native core and will be removed in a future release.
* It can now be installed and imported from `@react-native-community/slider` instead of 'react-native'.
* @see https://github.com/react-native-community/react-native-slider
* @see https://github.com/callstack/react-native-slider
* @deprecated
*/
export class Slider extends SliderBase {}
/** SliderIOS has been removed from react-native.
* It can now be installed and imported from `@react-native-community/slider` instead of 'react-native'.
* @see https://github.com/callstack/react-native-slider
* @deprecated
*/
export type SliderIOS = Slider;

/**
* https://facebook.github.io/react-native/docs/switchios.html#props
* SwitchIOS Component has been removed from react-native in favor of Switch Component
* https://github.com/facebook/react-native/pull/9891/files
* @deprecated see SwitchProps
*/
export interface SwitchIOSProps extends ViewProps {
/**
Expand Down Expand Up @@ -3643,13 +3655,9 @@ export interface SwitchIOSProps extends ViewProps {
}

/**
*
* Use SwitchIOS to render a boolean input on iOS.
*
* This is a controlled component, so you must hook in to the onValueChange callback and update the value prop in order for the component to update,
* otherwise the user's change will be reverted immediately to reflect props.value as the source of truth.
*
* @see https://facebook.github.io/react-native/docs/switchios.html
* SwitchIOS component has been removed from react-native in favor of Switch component
* https://github.com/facebook/react-native/pull/9891/files
* @deprecated see Switch
*/
export class SwitchIOS extends React.Component<SwitchIOSProps> {}

Expand Down Expand Up @@ -5889,6 +5897,10 @@ export interface TabBarIOSProps extends ViewProps {
unselectedItemTintColor?: ColorValue;
}

/**
* TabBarIOS has been removed from react-native
* @deprecated
*/
export class TabBarIOS extends React.Component<TabBarIOSProps> {
static Item: typeof TabBarIOSItem;
}
Expand Down Expand Up @@ -6677,7 +6689,7 @@ export interface ScrollViewProps extends ViewProps, ScrollViewPropsIOS, ScrollVi
* - `'normal'`: 0.998 on iOS, 0.985 on Android (the default)
* - `'fast'`: 0.99 on iOS, 0.9 on Android
*/
decelerationRate?: 'fast' | 'normal' | number,
decelerationRate?: 'fast' | 'normal' | number;

/**
* When true the scroll view's children are arranged horizontally in a row
Expand Down Expand Up @@ -9384,6 +9396,12 @@ export const DevSettings: DevSettingsStatic;
* @deprecated
*/
export const ART: ARTStatic;
/**
* ART has been removed from React Native.
* It can now be installed and imported from `@react-native-community/art` instead of 'react-native'.
* @see https://github.com/react-native-community/art
* @deprecated
*/
export type ART = ARTStatic;

//////////// APIS //////////////
Expand All @@ -9406,6 +9424,12 @@ export type AppState = AppStateStatic;
* @deprecated
*/
export const AsyncStorage: AsyncStorageStatic;
/**
* AsyncStorage has been extracted from react-native core and will be removed in a future release.
* It can now be installed and imported from `@react-native-community/async-storage` instead of 'react-native'.
* @see https://github.com/react-native-community/async-storage
* @deprecated
*/
export type AsyncStorage = AsyncStorageStatic;

export const BackHandler: BackHandlerStatic;
Expand All @@ -9418,6 +9442,12 @@ export type BackHandler = BackHandlerStatic;
* @deprecated
*/
export const CameraRoll: CameraRollStatic;
/**
* CameraRoll has been removed from React Native.
* It can now be installed and imported from `@react-native-community/cameraroll` instead of 'react-native'.
* @see https://github.com/react-native-community/react-native-cameraroll
* @deprecated
*/
export type CameraRoll = CameraRollStatic;

/**
Expand All @@ -9427,6 +9457,12 @@ export type CameraRoll = CameraRollStatic;
* @deprecated
*/
export const Clipboard: ClipboardStatic;
/**
* Clipboard has been extracted from react-native core and will be removed in a future release.
* It can now be installed and imported from `@react-native-community/clipboard` instead of 'react-native'.
* @see https://github.com/react-native-community/clipboard
* @deprecated
*/
export type Clipboard = ClipboardStatic;

/**
Expand All @@ -9436,6 +9472,12 @@ export type Clipboard = ClipboardStatic;
* @deprecated
*/
export const DatePickerAndroid: DatePickerAndroidStatic;
/**
* DatePickerAndroid has been merged with DatePickerIOS and will be removed in a future release.
* It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
* @see https://github.com/react-native-community/datetimepicker
* @deprecated
*/
export type DatePickerAndroid = DatePickerAndroidStatic;

export const Dimensions: Dimensions;
Expand Down Expand Up @@ -9502,6 +9544,12 @@ export type PermissionsAndroid = PermissionsAndroidStatic;
* @deprecated
*/
export const PushNotificationIOS: PushNotificationIOSStatic;
/**
* PushNotificationIOS has been extracted from react-native core and will be removed in a future release.
* It can now be installed and imported from `@react-native-community/push-notification-ios` instead of 'react-native'.
* @see https://github.com/react-native-community/react-native-push-notification-ios
* @deprecated
*/
export type PushNotificationIOS = PushNotificationIOSStatic;

export const Settings: SettingsStatic;
Expand All @@ -9526,6 +9574,12 @@ export type Systrace = SystraceStatic;
* @deprecated
*/
export const TimePickerAndroid: TimePickerAndroidStatic;
/**
* TimePickerAndroid has been removed from React Native.
* It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
* @see https://github.com/react-native-community/datetimepicker
* @deprecated
*/
export type TimePickerAndroid = TimePickerAndroidStatic;

export const ToastAndroid: ToastAndroidStatic;
Expand Down Expand Up @@ -9603,6 +9657,11 @@ export function findNodeHandle(

export function processColor(color?: number | ColorValue): ProcessedColorValue | null | undefined;

/**
* YellowBox has been replaced with LogBox.
* @see LogBox
* @deprecated
*/
export const YellowBox: React.ComponentClass<any, any> & { ignoreWarnings: (warnings: string[]) => void };

/**
Expand Down
11 changes: 8 additions & 3 deletions types/react-native/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ The content of index.io.js could be something like

'use strict';

import { AppRegistry } from 'react-native'
import Welcome from './gen/Welcome'
import { AppRegistry } from 'react-native'
import Welcome from './gen/Welcome'

AppRegistry.registerComponent('MopNative', () => Welcome);
AppRegistry.registerComponent('MopNative', () => Welcome);

For a list of complete Typescript examples: check https://github.com/bgrieder/RNTSExplorer
*/

import * as PropTypes from 'prop-types';
import * as React from 'react';
import {
ART,
AccessibilityInfo,
AsyncStorage,
Alert,
AppState,
AppStateStatus,
Expand Down Expand Up @@ -62,10 +64,12 @@ import {
NativeSyntheticEvent,
PermissionsAndroid,
Picker,
PickerIOS,
Platform,
PlatformColor,
Pressable,
ProgressBarAndroid,
ProgressViewIOS,
PushNotificationIOS,
RefreshControl,
RegisteredStyle,
Expand All @@ -82,6 +86,7 @@ import {
StyleProp,
StyleSheet,
Switch,
SwitchIOS,
Systrace,
TabBarIOS,
Text,
Expand Down