Skip to content

Commit 9bed84a

Browse files
authored
Fix TS errors that started after @tyes/react v18 (#2001)
* Fix TS errors that started after @tyes/react v18 * Remove fake classes for old docs
1 parent e05238b commit 9bed84a

File tree

34 files changed

+123
-132
lines changed

34 files changed

+123
-132
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"@types/jest": "^27.4.1",
6868
"@types/lodash": "^4.0.0",
6969
"@types/prop-types": "^15.5.3",
70-
"@types/react": "^17.0.44",
7170
"@types/react-native": "0.66.4",
7271
"@types/tinycolor2": "^1.4.2",
7372
"@types/url-parse": "^1.4.3",

src/components/actionSheet/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ class ActionSheet extends Component<ActionSheetProps> {
163163
key={index}
164164
testID={option.testID}
165165
onPress={() => this.onOptionPress(index)}
166-
// @ts-expect-error
167166
activeBackgroundColor={Colors.grey80}
168167
>
169168
<View row paddingL-16 flex centerV>

src/components/avatar/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import React, {PureComponent} from 'react';
2+
import React, {PropsWithChildren, PureComponent} from 'react';
33
import {
44
StyleSheet,
55
ImageSourcePropType,
@@ -49,7 +49,7 @@ export type AutoColorsProps = {
4949
defaultColor?: string;
5050
};
5151

52-
export type AvatarProps = Pick<AccessibilityProps, 'accessibilityLabel'> & {
52+
export type AvatarProps = Pick<AccessibilityProps, 'accessibilityLabel'> & PropsWithChildren<{
5353
/**
5454
* Adds fade in animation when Avatar image loads
5555
*/
@@ -153,7 +153,7 @@ export type AvatarProps = Pick<AccessibilityProps, 'accessibilityLabel'> & {
153153
* Used as a testing identifier
154154
*/
155155
testID?: string;
156-
};
156+
}>;
157157

158158
/**
159159
* @description: Avatar component for displaying user profile images

src/components/chip/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ const Chip = ({
165165
...others
166166
}: ChipProps) => {
167167

168-
const renderIcon = useCallback((iconPosition) => {
168+
const renderIcon = useCallback((iconPosition: 'left' | 'right') => {
169169
const isLeftIcon = iconPosition === 'left';
170170

171171
return (

src/components/dialog/OverlayFadingBackground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const OverlayFadingBackground = ({
2727
propsOnFadeDone?.();
2828
}, [propsOnFadeDone]);
2929

30-
const animateFading = useCallback((toValue) => {
30+
const animateFading = useCallback((toValue: number) => {
3131
isAnimating.current = true;
3232
Animated.timing(fadeAnimation, {
3333
toValue,

src/components/dialog/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export interface DialogProps extends AlignmentModifiers, RNPartialProps {
8282
* Used as a testing identifier
8383
*/
8484
testID?: string;
85+
children?: React.ReactNode;
8586
}
8687

8788
interface DialogState {

src/components/drawer/index.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {LogService} from '../../services';
1313
const DEFAULT_BG = Colors.primary;
1414
const DEFAULT_BOUNCINESS = 0;
1515

16-
interface ItemProps {
16+
interface DrawerItemProps {
1717
width?: number;
1818
background?: string;
1919
text?: string;
@@ -25,7 +25,7 @@ interface ItemProps {
2525
customElement?: ReactNode;
2626
}
2727

28-
interface Props {
28+
interface DrawerProps {
2929
/**
3030
* The drawer animation bounciness
3131
*/
@@ -37,11 +37,11 @@ interface Props {
3737
/**
3838
* The bottom layer's items to appear when opened from the right
3939
*/
40-
rightItems?: ItemProps[];
40+
rightItems?: DrawerItemProps[];
4141
/**
4242
* The bottom layer's item to appear when opened from the left (a single item)
4343
*/
44-
leftItem?: ItemProps;
44+
leftItem?: DrawerItemProps;
4545
/**
4646
* Set a different minimum width
4747
*/
@@ -126,19 +126,17 @@ interface Props {
126126
* Used as testing identifier
127127
*/
128128
testID?: string;
129+
children?: React.ReactNode;
129130
}
130131

131-
export type DrawerProps = Props;
132-
export type DrawerItemProps = ItemProps;
133-
134132
/**
135133
* @description: Drawer Component
136134
* @important: If your app works with RNN, your screen must be wrapped
137135
* with gestureHandlerRootHOC from 'react-native-gesture-handler'. see
138136
* @importantLink: https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html#with-wix-react-native-navigation-https-githubcom-wix-react-native-navigation
139137
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/Drawer/Drawer.gif?raw=true
140138
*/
141-
class Drawer extends PureComponent<Props> {
139+
class Drawer extends PureComponent<DrawerProps> {
142140
static displayName = 'Drawer';
143141

144142
static defaultProps = {
@@ -171,7 +169,7 @@ class Drawer extends PureComponent<Props> {
171169
return this.getActionsContainerStyle(Constants.isRTL ? [leftItem] : rightItems);
172170
});
173171

174-
private getActionsContainerStyle(items: ItemProps[]) {
172+
private getActionsContainerStyle(items: DrawerItemProps[]) {
175173
return {backgroundColor: _.get(_.first(items), 'background', DEFAULT_BG)};
176174
}
177175

@@ -203,7 +201,7 @@ class Drawer extends PureComponent<Props> {
203201

204202
/** Events */
205203

206-
private onActionPress = (item: ItemProps) => {
204+
private onActionPress = (item: DrawerItemProps) => {
207205
if (!item.keepOpen) {
208206
this.closeDrawer();
209207
}
@@ -296,7 +294,7 @@ class Drawer extends PureComponent<Props> {
296294
return this.renderActions(rightItems, progress /* , dragX */);
297295
};
298296

299-
private renderActions(items: ItemProps[] | undefined, progress: Animated.Value /* , dragX: Animated.Value */) {
297+
private renderActions(items: DrawerItemProps[] | undefined, progress: Animated.Value /* , dragX: Animated.Value */) {
300298
if (items) {
301299
return (
302300
// @ts-ignore
@@ -333,6 +331,7 @@ class Drawer extends PureComponent<Props> {
333331
});
334332

335333
return (
334+
// @ts-expect-error related to missing children type started on react 18
336335
<RectButton
337336
key={index}
338337
testID={item.testID}
@@ -417,6 +416,7 @@ class Drawer extends PureComponent<Props> {
417416
}
418417
}
419418

419+
export {DrawerProps, DrawerItemProps};
420420
export default asBaseComponent<DrawerProps, typeof Drawer>(Drawer);
421421

422422
const styles = StyleSheet.create({

src/components/gridList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function GridList<T = any>(props: GridListProps<T>) {
3030
return [{paddingHorizontal: listPadding}, contentContainerStyle];
3131
}, [listPadding, contentContainerStyle]);
3232

33-
const _renderItem = useCallback((...args) => {
33+
const _renderItem = useCallback((...args: any[]) => {
3434
// @ts-expect-error
3535
return <View style={itemContainerStyle}>{renderItem?.(...args)}</View>;
3636
},

src/components/gridListItem/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export interface GridListItemProps {
101101
* Test ID for component
102102
*/
103103
testID?: string;
104+
children?: React.ReactNode;
104105
}
105106

106107
interface RenderContentType {

src/components/hint/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export interface HintProps {
144144
* Additional styling
145145
*/
146146
style?: StyleProp<ViewStyle>;
147+
children?: React.ReactNode;
147148
}
148149

149150
interface HintState {

src/components/listItem/ListItemPart.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import {asBaseComponent} from '../../commons/new';
44
import View from '../view';
55
import {ListItemPartProps} from './types';
66

7+
/**
8+
* @description: ListItem.Part, a sub ListItem component for layout-ing inside a ListItem
9+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/BasicListScreen.tsx
10+
*/
711
class ListItemPart extends Component<ListItemPartProps> {
812
static displayName = 'ListItem.Part';
913

src/components/listItem/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ type ListItemState = {
1111
pressed: boolean;
1212
};
1313

14+
/**
15+
* @description: List item component to render inside a List component
16+
* @extends: TouchableOpacity
17+
* @gif: https://media.giphy.com/media/l1IBjHowyPcOTWAY8/giphy.gif
18+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/BasicListScreen.tsx
19+
*/
1420
class ListItem extends Component<ListItemProps, ListItemState> {
1521
static displayName = 'ListItem';
1622

@@ -54,6 +60,7 @@ class ListItem extends Component<ListItemProps, ListItemState> {
5460

5561
renderCustomContainer = (Container: React.ComponentType) => {
5662
const {...others} = this.props;
63+
// @ts-expect-error
5764
return <Container {...others}>{this.renderChildren()}</Container>;
5865
};
5966

src/components/listItem/types.tsx

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
import {PureComponent} from 'react';
1+
import {PropsWithChildren} from 'react';
22
import {StyleProp, ViewStyle} from 'react-native';
33
import {TouchableOpacityProps} from '../touchableOpacity';
44

5-
export type ListItemProps = {
6-
/**
7-
* the list item height
8-
*/
9-
height?: ViewStyle['height'];
10-
/**
11-
* action for when pressing the item
12-
*/
13-
onPress?: () => void;
14-
/**
15-
* action for when long pressing the item
16-
*/
17-
onLongPress?: () => void;
18-
/**
19-
* Additional styles for the top container
20-
*/
21-
containerStyle?: ViewStyle;
22-
/**
23-
* The container element to wrap the ListItem
24-
*/
25-
containerElement?: React.ComponentType<ListItemProps | TouchableOpacityProps>;
26-
/**
27-
* The inner element style
28-
*/
29-
style?: ViewStyle;
30-
/**
31-
* The inner element pressed backgroundColor
32-
*/
33-
underlayColor?: string;
5+
export type ListItemProps = TouchableOpacityProps &
6+
PropsWithChildren<{
7+
/**
8+
* the list item height
9+
*/
10+
height?: ViewStyle['height'];
11+
/**
12+
* action for when pressing the item
13+
*/
14+
onPress?: () => void;
15+
/**
16+
* action for when long pressing the item
17+
*/
18+
onLongPress?: () => void;
19+
/**
20+
* Additional styles for the top container
21+
*/
22+
containerStyle?: ViewStyle;
23+
/**
24+
* The container element to wrap the ListItem
25+
*/
26+
containerElement?: React.ComponentType<ListItemProps | TouchableOpacityProps>;
27+
/**
28+
* The inner element style
29+
*/
30+
style?: ViewStyle;
31+
/**
32+
* The inner element pressed backgroundColor
33+
*/
34+
underlayColor?: string;
3435

35-
testID?: string;
36-
};
36+
testID?: string;
37+
}>;
3738

38-
export type ListItemPartProps = {
39+
export type ListItemPartProps = PropsWithChildren<{
3940
/**
4041
* this part content will be aligned to left
4142
*/
@@ -60,33 +61,4 @@ export type ListItemPartProps = {
6061
* container style
6162
*/
6263
containerStyle?: StyleProp<ViewStyle>;
63-
};
64-
65-
/**
66-
* @description: List item component to render inside a List component
67-
* @extends: TouchableOpacity
68-
* @gif: https://media.giphy.com/media/l1IBjHowyPcOTWAY8/giphy.gif
69-
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/BasicListScreen.tsx
70-
*/
71-
// @ts-ignore
72-
class FakeListItemForDocs extends PureComponent<ListItemProps> { // eslint-disable-line
73-
static displayName = 'ListItem';
74-
75-
render() {
76-
return null;
77-
}
78-
}
79-
80-
81-
/**
82-
* @description: ListItem.Part, a sub ListItem component for layout-ing inside a ListItem
83-
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/BasicListScreen.tsx
84-
*/
85-
// @ts-ignore
86-
class FakeListItemPartForDocs extends PureComponent<ListItemPartProps> { // eslint-disable-line
87-
static displayName = 'ListItemPart';
88-
89-
render() {
90-
return null;
91-
}
92-
}
64+
}>;

src/components/panningViews/panDismissibleView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface PanDismissibleViewProps {
5454
* since it looks better and most cases.
5555
*/
5656
allowDiagonalDismiss?: boolean;
57+
children?: React.ReactNode;
5758
}
5859

5960
const DEFAULT_DIRECTIONS = [

0 commit comments

Comments
 (0)