Skip to content

Commit b8412d9

Browse files
committed
Fix ts errors
1 parent 2bd0e58 commit b8412d9

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

example/src/ImageCropper.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { Image, Platform, ScrollView } from 'react-native';
44
import { NativeSyntheticEvent } from 'react-native/Libraries/Types/CoreEventTypes';
55
import { NativeScrollEvent } from 'react-native/Libraries/Components/ScrollView/ScrollView';
66

7-
import type { ImageSourcePropType, StyleProp, ViewStyle } from 'react-native';
7+
import type { ImageURISource, StyleProp, ViewStyle } from 'react-native';
88
import type { ImageCropData, ImageOffset, ImageSize } from './types';
99

1010
export interface ImageCropperProps {
11-
image: ImageSize & ImageSourcePropType;
11+
image: ImageSize & Pick<ImageURISource, 'uri'>;
1212
size: ImageSize;
1313
onTransformDataChange?: (data: ImageCropData) => void;
1414
style?: StyleProp<ViewStyle>;

example/src/SquareImageCropper.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import { ImageCropper } from './ImageCropper';
1818
import type { ImageCropData, ImageSize } from './types';
1919

2020
interface State {
21-
croppedImageURI: string | null;
21+
croppedImageURI: string | undefined;
2222
cropError: Error | null;
2323
measuredSize: ImageSize | null;
2424
cropScale: number;
25-
photo: ImageURISource;
25+
photo: ImageSize & Pick<ImageURISource, 'uri'>;
2626
}
2727
interface Props {
2828
// noop
@@ -40,7 +40,7 @@ export class SquareImageCropper extends Component<Props, State> {
4040
width: DEFAULT_IMAGE_WIDTH,
4141
},
4242
measuredSize: null,
43-
croppedImageURI: null,
43+
croppedImageURI: undefined,
4444
cropError: null,
4545
cropScale: 1,
4646
};
@@ -76,7 +76,7 @@ export class SquareImageCropper extends Component<Props, State> {
7676
_renderImageCropper() {
7777
const { photo, cropError, measuredSize } = this.state;
7878

79-
if (!photo) {
79+
if (!photo || !measuredSize) {
8080
return <SafeAreaView style={styles.container} />;
8181
}
8282

@@ -172,7 +172,11 @@ export class SquareImageCropper extends Component<Props, State> {
172172
};
173173

174174
_reset = () => {
175-
this.setState({ croppedImageURI: null, cropError: null, cropScale: 1 });
175+
this.setState({
176+
croppedImageURI: undefined,
177+
cropError: null,
178+
cropScale: 1,
179+
});
176180
};
177181
}
178182

src/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ function toHeadersObject(
3131
headers: ImageCropData['headers']
3232
): Record<string, string> | undefined {
3333
return headers instanceof Headers
34-
? Object.fromEntries(
35-
// @ts-expect-error: Headers.entries isn't added yet in TS but exists in Runtime
36-
headers.entries()
37-
)
34+
? Object.fromEntries(headers.entries())
3835
: headers;
3936
}
4037

0 commit comments

Comments
 (0)