Skip to content

Commit f6f79d4

Browse files
authored
feat: enforce import type for the type imports (#2026)
1 parent 7d4e006 commit f6f79d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1024
-731
lines changed

example/src/ExampleList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { FlatList } from 'react-native';
33
import { List, Divider, useTheme } from 'react-native-paper';
44
import { useSafeArea } from 'react-native-safe-area-context';
5-
import { StackNavigationProp } from '@react-navigation/stack';
5+
import type { StackNavigationProp } from '@react-navigation/stack';
66

77
import ActivityIndicatorExample from './Examples/ActivityIndicatorExample';
88
import AppbarExample from './Examples/AppbarExample';

example/src/Examples/AppbarExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { View, Platform, StyleSheet } from 'react-native';
3-
import { StackNavigationProp } from '@react-navigation/stack';
3+
import type { StackNavigationProp } from '@react-navigation/stack';
44
import {
55
Colors,
66
Appbar,

example/src/Examples/MenuExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Platform,
66
GestureResponderEvent,
77
} from 'react-native';
8-
import { StackNavigationProp } from '@react-navigation/stack';
8+
import type { StackNavigationProp } from '@react-navigation/stack';
99
import {
1010
Menu,
1111
Appbar,

example/src/Examples/SearchbarExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { StyleSheet, View } from 'react-native';
33
import { Colors, Caption, Searchbar, useTheme } from 'react-native-paper';
4-
import { StackNavigationProp } from '@react-navigation/stack';
4+
import type { StackNavigationProp } from '@react-navigation/stack';
55

66
type Props = {
77
navigation: StackNavigationProp<{}>;

example/src/RootNavigator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { Appbar } from 'react-native-paper';
3-
import { DrawerNavigationProp } from '@react-navigation/drawer';
3+
import type { DrawerNavigationProp } from '@react-navigation/drawer';
44
import { createStackNavigator } from '@react-navigation/stack';
55
import ExampleList, { examples } from './ExampleList';
66

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
"react-native-safe-area-view": "^0.14.9"
5252
},
5353
"devDependencies": {
54-
"@babel/core": "^7.4.4",
55-
"@babel/runtime": "^7.4.4",
54+
"@babel/core": "^7.10.3",
55+
"@babel/runtime": "^7.10.3",
5656
"@callstack/eslint-config": "^9.0.0",
5757
"@commitlint/config-conventional": "^8.3.4",
5858
"@react-native-community/bob": "^0.16.0",
@@ -68,7 +68,7 @@
6868
"all-contributors-cli": "^6.1.1",
6969
"babel-cli": "^6.26.0",
7070
"babel-core": "^7.0.0-bridge.0",
71-
"babel-jest": "^24.3.1",
71+
"babel-jest": "^26.1.0",
7272
"babel-test": "^0.1.1",
7373
"chalk": "^4.0.0",
7474
"commitlint": "^8.3.4",
@@ -81,9 +81,9 @@
8181
"flow-bin": "0.92.0",
8282
"glob": "^7.1.3",
8383
"husky": "^1.3.1",
84-
"jest": "^24.9.0",
84+
"jest": "^26.1.0",
8585
"jest-file-snapshot": "^0.3.2",
86-
"metro-react-native-babel-preset": "^0.56.0",
86+
"metro-react-native-babel-preset": "^0.59.0",
8787
"prettier": "^2.0.5",
8888
"react": "16.11.0",
8989
"react-dom": "16.11.0",

src/components/Appbar/AppbarAction.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import * as React from 'react';
22
import color from 'color';
3-
import { StyleProp, ViewStyle, TouchableWithoutFeedback } from 'react-native';
3+
import type {
4+
StyleProp,
5+
ViewStyle,
6+
TouchableWithoutFeedback,
7+
} from 'react-native';
48
import { black } from '../../styles/colors';
59
import IconButton from '../IconButton';
6-
import { IconSource } from '../Icon';
10+
import type { IconSource } from '../Icon';
711

812
type Props = React.ComponentPropsWithoutRef<typeof IconButton> & {
913
/**

src/components/Appbar/AppbarBackAction.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
StyleProp,
99
ViewStyle,
1010
} from 'react-native';
11-
import { $Omit } from './../../types';
11+
import type { $Omit } from './../../types';
1212
import AppbarAction from './AppbarAction';
1313
import MaterialCommunityIcon from '../MaterialCommunityIcon';
1414

src/components/Appbar/AppbarContent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Text from '../Typography/Text';
1515
import { withTheme } from '../../core/theming';
1616
import { white } from '../../styles/colors';
1717

18-
import { $RemoveChildren } from '../../types';
18+
import type { $RemoveChildren } from '../../types';
1919

2020
type Props = $RemoveChildren<typeof View> & {
2121
/**

src/components/Avatar/AvatarIcon.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import color from 'color';
44
import Icon from '../Icon';
55
import { withTheme } from '../../core/theming';
66
import { white } from '../../styles/colors';
7-
import { IconSource } from './../Icon';
7+
import type { IconSource } from './../Icon';
88

99
const defaultSize = 64;
1010

src/components/Banner.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Text from './Typography/Text';
55
import Button from './Button';
66
import Icon, { IconSource } from './Icon';
77
import { withTheme } from '../core/theming';
8-
import { $RemoveChildren } from '../types';
8+
import type { $RemoveChildren } from '../types';
99
import shadow from '../styles/shadow';
1010

1111
const ELEVATION = 1;

src/components/Checkbox/CheckboxAndroid.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import color from 'color';
44
import MaterialCommunityIcon from '../MaterialCommunityIcon';
55
import TouchableRipple from '../TouchableRipple';
66
import { withTheme } from '../../core/theming';
7-
import { $RemoveChildren } from '../../types';
7+
import type { $RemoveChildren } from '../../types';
88

99
type Props = $RemoveChildren<typeof TouchableRipple> & {
1010
/**

src/components/Checkbox/CheckboxIOS.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import color from 'color';
44
import MaterialCommunityIcon from '../MaterialCommunityIcon';
55
import TouchableRipple from '../TouchableRipple';
66
import { withTheme } from '../../core/theming';
7-
import { $RemoveChildren } from '../../types';
7+
import type { $RemoveChildren } from '../../types';
88

99
type Props = $RemoveChildren<typeof TouchableRipple> & {
1010
/**

src/components/DataTable/DataTableCell.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { StyleSheet, StyleProp, ViewStyle } from 'react-native';
33
import Text from '../Typography/Text';
44
import TouchableRipple from '../TouchableRipple';
5-
import { $RemoveChildren } from '../../types';
5+
import type { $RemoveChildren } from '../../types';
66

77
type Props = $RemoveChildren<typeof TouchableRipple> & {
88
/**

src/components/DataTable/DataTableRow.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { StyleSheet, StyleProp, View, ViewStyle } from 'react-native';
44
import TouchableRipple from '../TouchableRipple';
55
import { black, white } from '../../styles/colors';
66
import { withTheme } from '../../core/theming';
7-
import { $RemoveChildren } from '../../types';
7+
import type { $RemoveChildren } from '../../types';
88

99
type Props = $RemoveChildren<typeof TouchableRipple> & {
1010
/**

src/components/Divider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import color from 'color';
33
import { StyleSheet, View, ViewStyle, StyleProp } from 'react-native';
44
import { withTheme } from '../core/theming';
55
import { black, white } from '../styles/colors';
6-
import { $RemoveChildren } from '../types';
6+
import type { $RemoveChildren } from '../types';
77

88
type Props = $RemoveChildren<typeof View> & {
99
/**

src/components/FAB/FAB.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import Text from '../Typography/Text';
1010
import TouchableRipple from '../TouchableRipple';
1111
import { black, white } from '../../styles/colors';
1212
import { withTheme } from '../../core/theming';
13-
import { $RemoveChildren } from '../../types';
14-
import { IconSource } from './../Icon';
13+
import type { $RemoveChildren } from '../../types';
14+
import type { IconSource } from './../Icon';
1515

1616
type Props = $RemoveChildren<typeof Surface> & {
1717
/**

src/components/FAB/FABGroup.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import FAB from './FAB';
1313
import Text from '../Typography/Text';
1414
import Card from '../Card/Card';
1515
import { withTheme } from '../../core/theming';
16-
import { IconSource } from '../Icon';
16+
import type { IconSource } from '../Icon';
1717

1818
type Props = {
1919
/**

src/components/HelperText.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from 'react-native';
1010
import AnimatedText from './Typography/AnimatedText';
1111
import { withTheme } from '../core/theming';
12-
import { $Omit } from '../types';
12+
import type { $Omit } from '../types';
1313

1414
type Props = $Omit<
1515
$Omit<React.ComponentPropsWithRef<typeof AnimatedText>, 'padding'>,

src/components/IconButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Icon, { IconSource } from './Icon';
1414
import CrossFadeIcon from './CrossFadeIcon';
1515
import { withTheme } from '../core/theming';
1616

17-
import { $RemoveChildren } from '../types';
17+
import type { $RemoveChildren } from '../types';
1818

1919
type Props = $RemoveChildren<typeof TouchableRipple> & {
2020
/**

src/components/List/ListItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import TouchableRipple from '../TouchableRipple';
1212
import Text from '../Typography/Text';
1313
import { withTheme } from '../../core/theming';
14-
import { $RemoveChildren, EllipsizeProp } from '../../types';
14+
import type { $RemoveChildren, EllipsizeProp } from '../../types';
1515

1616
type Description =
1717
| React.ReactNode

src/components/Menu/Menu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from 'react-native';
1818

1919
import { withTheme } from '../../core/theming';
20-
import { $Omit } from '../../types';
20+
import type { $Omit } from '../../types';
2121
import Portal from '../Portal/Portal';
2222
import Surface from '../Surface';
2323
// eslint-disable-next-line @typescript-eslint/no-unused-vars

src/components/Portal/PortalConsumer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { PortalMethods } from './PortalHost';
2+
import type { PortalMethods } from './PortalHost';
33

44
type Props = {
55
manager: PortalMethods;

src/components/RadioButton/RadioButtonAndroid.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RadioButtonContext, RadioButtonContextType } from './RadioButtonGroup';
55
import { handlePress, isChecked } from './utils';
66
import TouchableRipple from '../TouchableRipple';
77
import { withTheme } from '../../core/theming';
8-
import { $RemoveChildren } from '../../types';
8+
import type { $RemoveChildren } from '../../types';
99

1010
type Props = $RemoveChildren<typeof TouchableRipple> & {
1111
/**

src/components/RadioButton/RadioButtonIOS.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { handlePress, isChecked } from './utils';
66
import MaterialCommunityIcon from '../MaterialCommunityIcon';
77
import TouchableRipple from '../TouchableRipple';
88
import { withTheme } from '../../core/theming';
9-
import { $RemoveChildren } from '../../types';
9+
import type { $RemoveChildren } from '../../types';
1010

1111
type Props = $RemoveChildren<typeof TouchableRipple> & {
1212
/**

src/components/Searchbar.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import color from 'color';
1212
import IconButton from './IconButton';
1313
import Surface from './Surface';
1414
import { withTheme } from '../core/theming';
15-
import { IconSource } from './Icon';
15+
import type { IconSource } from './Icon';
1616
import MaterialCommunityIcon from './MaterialCommunityIcon';
1717

1818
type Props = React.ComponentPropsWithRef<typeof TextInput> & {
@@ -75,12 +75,12 @@ type Props = React.ComponentPropsWithRef<typeof TextInput> & {
7575
* ```js
7676
* import * as React from 'react';
7777
* import { Searchbar } from 'react-native-paper';
78-
*
78+
*
7979
* const MyComponent = () => {
8080
* const [searchQuery, setSearchQuery] = React.useState('');
81-
*
81+
*
8282
* const onChangeSearch = query => setSearchQuery(query);
83-
*
83+
*
8484
* return (
8585
* <Searchbar
8686
* placeholder="Search"
@@ -89,7 +89,7 @@ type Props = React.ComponentPropsWithRef<typeof TextInput> & {
8989
* />
9090
* );
9191
* };
92-
*
92+
*
9393
* export default MyComponent;
9494
9595
* ```

src/components/TextInput/Adornment/Icon.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
33

44
import IconButton from '../../IconButton';
5-
import { $Omit } from '../../../../src/types';
5+
import type { $Omit } from '../../../../src/types';
66

77
type Props = $Omit<
88
React.ComponentProps<typeof IconButton>,

src/components/TextInput/Adornment/TextInputAdornment.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Animated,
1010
Platform,
1111
} from 'react-native';
12-
import {
12+
import type {
1313
AdornmentConfig,
1414
AdornmentStyleAdjustmentForNativeInput,
1515
} from './types';

src/components/TextInput/Adornment/types.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AdornmentSide, AdornmentType } from './enums';
1+
import type { AdornmentSide, AdornmentType } from './enums';
22

33
export type AdornmentConfig = {
44
side: AdornmentSide;

src/components/TextInput/Label/InputLabel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { Animated, StyleSheet } from 'react-native';
33
import AnimatedText from '../../Typography/AnimatedText';
44

5-
import { InputLabelProps } from '../types';
5+
import type { InputLabelProps } from '../types';
66

77
const InputLabel = (props: InputLabelProps) => {
88
const { parentState, labelBackground } = props;

src/components/TextInput/Label/LabelBackground.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Animated, StyleSheet } from 'react-native';
33

44
import AnimatedText from '../../Typography/AnimatedText';
55

6-
import { LabelBackgroundProps } from '../types';
6+
import type { LabelBackgroundProps } from '../types';
77

88
const LabelBackground = ({
99
parentState,

src/components/TextInput/TextInput.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import TextInputFlat from './TextInputFlat';
1212
import TextInputIcon from './Adornment/Icon';
1313
import TextInputAffix from './Adornment/Affix';
1414
import { withTheme } from '../../core/theming';
15-
import { RenderProps, State } from './types';
16-
import { $Omit } from '../../types';
15+
import type { RenderProps, State } from './types';
16+
import type { $Omit } from '../../types';
1717

1818
const BLUR_ANIMATION_DURATION = 180;
1919
const FOCUS_ANIMATION_DURATION = 150;

src/components/TextInput/TextInputFlat.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import InputLabel from './Label/InputLabel';
1313
import TextInputAdornment, {
1414
TextInputAdornmentProps,
1515
} from './Adornment/TextInputAdornment';
16-
import { RenderProps, ChildTextInputProps } from './types';
16+
import type { RenderProps, ChildTextInputProps } from './types';
1717

1818
import {
1919
MAXIMIZED_LABEL_FONT_SIZE,

src/components/TextInput/TextInputOutlined.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import TextInputAdornment, {
1616

1717
import InputLabel from './Label/InputLabel';
1818
import LabelBackground from './Label/LabelBackground';
19-
import { RenderProps, ChildTextInputProps } from './types';
19+
import type { RenderProps, ChildTextInputProps } from './types';
2020

2121
import {
2222
MAXIMIZED_LABEL_FONT_SIZE,

src/components/TextInput/helpers.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Animated } from 'react-native';
2-
import { AdornmentConfig } from './Adornment/types';
1+
import type { Animated } from 'react-native';
2+
import type { AdornmentConfig } from './Adornment/types';
33
import {
44
LABEL_PADDING_HORIZONTAL,
55
ADORNMENT_OFFSET,

src/components/TextInput/types.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {
1+
import type {
22
TextInput as NativeTextInput,
33
Animated,
44
TextStyle,
55
LayoutChangeEvent,
66
} from 'react-native';
7-
import { TextInputProps } from './TextInput';
8-
import { $Omit } from './../../types';
7+
import type { TextInputProps } from './TextInput';
8+
import type { $Omit } from './../../types';
99

1010
export type RenderProps = {
1111
ref: (a: NativeTextInput | null | undefined) => void;

src/components/ToggleButton/ToggleButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ToggleButtonGroup, {
1313
} from './ToggleButtonGroup';
1414
import ToggleButtonRow from './ToggleButtonRow';
1515
import { black, white } from '../../styles/colors';
16-
import { IconSource } from '../Icon';
16+
import type { IconSource } from '../Icon';
1717

1818
type Props = {
1919
/**

src/components/__tests__/BottomNavigation.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import renderer from 'react-test-renderer';
33
import BottomNavigation from '../BottomNavigation.tsx';
44

5+
jest.useFakeTimers();
56
// Make sure any animation finishes before checking the snapshot results
67
jest.mock('react-native', () => {
78
const RN = jest.requireActual('react-native');

0 commit comments

Comments
 (0)