Skip to content

Commit 32b6850

Browse files
committed
Fix TS errors
1 parent 4e7d3a2 commit 32b6850

File tree

19 files changed

+37
-32
lines changed

19 files changed

+37
-32
lines changed

src/commons/asBaseComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, {PropsWithoutRef} from 'react';
22
import hoistStatics from 'hoist-non-react-statics';
33
import * as Modifiers from './modifiers';
44
import {Scheme, SchemeChangeListener, ThemeManager} from '../style';
@@ -23,7 +23,7 @@ const colorScheme = Scheme.getSchemeType();
2323

2424
function asBaseComponent<PROPS, STATICS = {}, RefInterface = any>(WrappedComponent: React.ComponentType<any>,
2525
options: AsBaseComponentOptions = {}) {
26-
class BaseComponent extends UIComponent<PROPS & ForwardRefInjectedProps<RefInterface>> {
26+
class BaseComponent extends UIComponent<PropsWithoutRef<PROPS> & ForwardRefInjectedProps<RefInterface>> {
2727
static displayName: string | undefined;
2828
static propTypes: any;
2929
static defaultProps: any;

src/commons/forwardRef.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {ComponentType, ForwardedRef} from 'react';
1+
import React, {ComponentType, ForwardedRef, PropsWithoutRef} from 'react';
22
import hoistStatics from 'hoist-non-react-statics';
33

44
export interface ForwardRefInjectedProps<T = any> {
@@ -8,8 +8,8 @@ export interface ForwardRefInjectedProps<T = any> {
88
forwardedRef: ForwardedRef<T>;
99
}
1010

11-
export default function forwardRef<P, STATICS = {}, RefInterface = any>(WrappedComponent: ComponentType<P & ForwardRefInjectedProps<RefInterface>>) {
12-
function forwardRef(props: P, ref: ForwardedRef<RefInterface>) {
11+
export default function forwardRef<P, STATICS = {}, RefInterface = any>(WrappedComponent: ComponentType<PropsWithoutRef<P> & ForwardRefInjectedProps<RefInterface>>) {
12+
function forwardRef(props: PropsWithoutRef<P>, ref: ForwardedRef<RefInterface>) {
1313
return <WrappedComponent {...props} forwardedRef={ref}/>;
1414
}
1515

src/commons/withScrollEnabler.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function withScrollEnabler<PROPS, STATICS = {}>(WrappedComponent: React.Componen
7373
ScrollEnabler.propTypes = WrappedComponent.propTypes;
7474
//@ts-ignore
7575
ScrollEnabler.defaultProps = WrappedComponent.defaultProps;
76+
// @ts-expect-error
7677
return forwardRef(ScrollEnabler) as any;
7778
}
7879

src/commons/withScrollReached.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function withScrollReached<PROPS, STATICS = {}>(WrappedComponent: React.Componen
9696
ScrollReachedDetector.propTypes = WrappedComponent.propTypes;
9797
//@ts-ignore
9898
ScrollReachedDetector.defaultProps = WrappedComponent.defaultProps;
99+
// @ts-expect-error
99100
return forwardRef<PROPS & PropTypes>(ScrollReachedDetector) as any;
100101
}
101102

src/components/actionSheet/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ class ActionSheet extends Component<ActionSheetProps> {
255255
}
256256

257257
return (
258-
// @ts-expect-error height might be null here
259258
<IncubatorDialog
260259
bottom
261260
centerH

src/components/button/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ const modifiersOptions = {
420420
typography: true,
421421
color: true
422422
};
423+
424+
// @ts-expect-error class components don't work well with forwardRef HOC
423425
export default asBaseComponent<ButtonProps, ComponentStatics<typeof Button>, {}>(forwardRef(Button), {
424426
modifiersOptions
425427
});

src/components/card/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22
import React, {PureComponent} from 'react';
3-
import {StyleSheet, Animated, StyleProp, ViewStyle} from 'react-native';
3+
import {StyleSheet, Animated, StyleProp, ViewStyle, type DimensionValue} from 'react-native';
44
import {Colors, BorderRadiuses} from '../../style';
55
// import {PureBaseComponent} from '../../commons';
66
import {Constants, asBaseComponent, forwardRef, BaseComponentInjectedProps, ForwardRefInjectedProps, MarginModifiers} from '../../commons/new';
@@ -42,11 +42,11 @@ export type CardProps = ViewProps &
4242
/**
4343
* card custom width
4444
*/
45-
width?: number | string;
45+
width?: DimensionValue;
4646
/**
4747
* card custom height
4848
*/
49-
height?: number | string;
49+
height?: DimensionValue;
5050
/**
5151
* should inner card flow direction be horizontal
5252
*/

src/components/dateTimePicker/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import React, {
88
forwardRef,
99
ForwardedRef
1010
} from 'react';
11-
import {StyleProp, StyleSheet, ViewStyle} from 'react-native';
11+
import {DimensionValue, StyleProp, StyleSheet, ViewStyle} from 'react-native';
1212
import {DateTimePickerPackage as RNDateTimePicker} from '../../optionalDependencies';
1313
import {useDidUpdate} from '../../hooks';
1414
import {Colors} from '../../style';
@@ -170,7 +170,7 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
170170

171171
const _dialogProps = useMemo(() => {
172172
return {
173-
width: '100%',
173+
width: '100%' as DimensionValue,
174174
height: null,
175175
bottom: true,
176176
centerH: true,

src/components/dialog/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
3-
import {StyleSheet, StyleProp, ViewStyle, ModalPropsIOS, AccessibilityProps} from 'react-native';
3+
import {StyleSheet, StyleProp, ViewStyle, ModalPropsIOS, AccessibilityProps, type DimensionValue} from 'react-native';
44
import {Colors} from '../../style';
55
import {AlignmentModifiers, extractAlignmentsValues} from '../../commons/modifiers';
66
import {Constants, asBaseComponent} from '../../commons/new';
@@ -42,11 +42,11 @@ export interface DialogProps extends AlignmentModifiers, RNPartialProps {
4242
/**
4343
* The dialog width (default: 90%)
4444
*/
45-
width?: string | number;
45+
width?: DimensionValue;
4646
/**
4747
* The dialog height (default: undefined)
4848
*/
49-
height?: string | number | null;
49+
height?: DimensionValue | null;
5050
/**
5151
* The direction of the allowed pan (default is DOWN).
5252
* Types: UP, DOWN, LEFT and RIGHT (using PanningProvider.Directions.###).

src/components/fader/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22
import React, {useMemo} from 'react';
3-
import {StyleSheet} from 'react-native';
3+
import {StyleSheet, StyleProp, ImageStyle} from 'react-native';
44
import View from '../view';
55
import Image, {ImageProps} from '../image';
66
import {Colors} from 'style';
@@ -47,7 +47,7 @@ function Fader(props: FaderProps) {
4747
} = props;
4848

4949
const styles = useMemo(() => {
50-
let containerStyle, imageStyle, imageSource;
50+
let containerStyle, imageStyle: StyleProp<ImageStyle>, imageSource;
5151
switch (position) {
5252
case FaderPosition.START:
5353
containerStyle = {...staticStyles.containerLeft, width: size};

src/components/gridListItem/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
3-
import {StyleProp, StyleSheet, ViewStyle} from 'react-native';
3+
import {type DimensionValue, StyleProp, StyleSheet, ViewStyle} from 'react-native';
44
import memoize from 'memoize-one';
55
import * as Modifiers from '../../commons/modifiers';
66
import {Spacings} from 'style';
@@ -274,6 +274,6 @@ const styles = StyleSheet.create({
274274
export default GridListItem;
275275

276276
interface ImageSize {
277-
width?: number | string;
278-
height?: number | string;
277+
width?: DimensionValue;
278+
height?: DimensionValue;
279279
}

src/components/picker/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// TODO: consider deprecating renderCustomModal prop
44
import _ from 'lodash';
55
import React, {useMemo, useState, useRef, useCallback, useEffect} from 'react';
6-
import {LayoutChangeEvent} from 'react-native';
6+
import {DimensionValue, LayoutChangeEvent} from 'react-native';
77
import {useThemeProps} from 'hooks';
88
import {Constants} from '../../commons/new';
99
import ExpandableOverlay, {ExpandableOverlayProps, ExpandableOverlayMethods} from '../../incubator/expandableOverlay';
@@ -33,7 +33,7 @@ import {
3333

3434
const DIALOG_PROPS = {
3535
bottom: true,
36-
width: '100%',
36+
width: '100%' as DimensionValue,
3737
height: 250
3838
};
3939

src/components/slider/Thumb.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ const Thumb = forwardRef((props: ThumbProps, ref: any) => {
126126

127127
return (
128128
<Animated.View
129+
// @ts-expect-error
129130
ref={thumbRef}
130131
{...others}
131132
hitSlop={thumbHitSlop}

src/components/slider/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ type Measurements = {
4545
height: number;
4646
};
4747

48-
type ThumbStyle = {style?: StyleProp<ViewStyle>; left?: StyleProp<number>};
48+
type ThumbStyle = {style?: StyleProp<ViewStyle>; left?: number};
4949

50-
type MinTrackStyle = {style?: StyleProp<ViewStyle>; width?: StyleProp<number>; left?: StyleProp<number>};
50+
type MinTrackStyle = {style?: StyleProp<ViewStyle>; width?: number; left?: number};
5151

5252
type MeasuredVariableName = 'containerSize' | 'trackSize' | 'thumbSize';
5353

src/components/text/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,6 @@ const modifiersOptions = {
225225
backgroundColor: true,
226226
flex: true
227227
};
228+
229+
// @ts-expect-error class components don't work well with forwardRef HOC
228230
export default asBaseComponent<TextProps>(forwardRef<PropsTypes>(Text), {modifiersOptions});

src/components/view/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {useModifiers, useThemeProps} from 'hooks';
22
import React, {useEffect, useMemo, useState} from 'react';
3-
import {View as RNView, SafeAreaView, Animated, ViewProps as RNViewProps, StyleProp, ViewStyle} from 'react-native';
3+
import {View as RNView, SafeAreaView, Animated, ViewProps as RNViewProps, type StyleProp, type ViewStyle, type DimensionValue} from 'react-native';
44
import type {AnimateProps as RNReanimatedProps} from 'react-native-reanimated';
55
import {Constants, ContainerModifiers} from '../../commons/new';
66
import type {RecorderProps} from '../../typings/recorderTypes';
@@ -30,11 +30,11 @@ export interface ViewProps extends Omit<RNViewProps, 'style'>, ReanimatedProps,
3030
/**
3131
* TODO: probably isn't needed
3232
*/
33-
width?: string | number;
33+
width?: DimensionValue;
3434
/**
3535
* TODO: probably isn't needed
3636
*/
37-
height?: string | number;
37+
height?: DimensionValue;
3838
/**
3939
* Experimental: Pass time in ms to delay render
4040
*/

src/hooks/useCombinedRefs/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
const useCombinedRefs = (...refs: React.Ref<any>[]) => {
3+
const useCombinedRefs = <T>(...refs: React.Ref<any>[]) => {
44
const targetRef = React.useRef();
55

66
React.useEffect(() => {
@@ -17,7 +17,7 @@ const useCombinedRefs = (...refs: React.Ref<any>[]) => {
1717
});
1818
}, [refs]);
1919

20-
return targetRef;
20+
return targetRef as T;
2121
};
2222

2323
export default useCombinedRefs;

src/incubator/Dialog/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {PropsWithChildren, ReactElement} from 'react';
2-
import {StyleProp, TextStyle, ViewStyle} from 'react-native';
2+
import {type DimensionValue, type StyleProp, type TextStyle, type ViewStyle} from 'react-native';
33
import {AlignmentModifiers} from '../../commons/modifiers';
44
import {DialogProps as DialogPropsOld} from '../../components/dialog';
55
import {ButtonProps} from '../../components/button';
@@ -101,11 +101,11 @@ export interface _DialogProps extends AlignmentModifiers, Pick<ViewProps, 'useSa
101101
/**
102102
* The dialog width.
103103
*/
104-
width?: string | number;
104+
width?: DimensionValue;
105105
/**
106106
* The dialog height.
107107
*/
108-
height?: string | number;
108+
height?: DimensionValue;
109109

110110
/**
111111
* Callback that is called after the dialog's dismiss (after the animation has ended).

src/incubator/expandableOverlay/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ const ExpandableOverlay = (props: ExpandableOverlayProps, ref: any) => {
106106
const renderDialog = () => {
107107
const Dialog = migrateDialog ? DialogNew : DialogOld;
108108
return (
109-
// @ts-expect-error
110109
<Dialog testID={`${testID}.overlay`} {...dialogProps} visible={visible} onDismiss={closeExpandable}>
111110
{expandableContent}
112111
</Dialog>

0 commit comments

Comments
 (0)