Skip to content

Commit ac309ec

Browse files
committed
fix: resolve build and lint errors from component migration
- Fix ImageComponent type in Reply.tsx (required, not optional) - Replace React.ComponentType<any> with proper types (ImageProps, ImageGalleryHeaderProps, etc.) to satisfy no-explicit-any lint rule - Add missing ImageProps imports in URLPreview/URLPreviewCompact - Fix prettier formatting
1 parent b34c3f0 commit ac309ec

File tree

8 files changed

+46
-27
lines changed

8 files changed

+46
-27
lines changed

package/src/components/Attachment/GalleryImage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useComponentsContext } from '../../contexts/componentsContext/Component
66
import { getUrlWithoutParams, isLocalUrl, makeImageCompatibleUrl } from '../../utils/utils';
77

88
export type GalleryImageWithContextProps = GalleryImageProps & {
9-
ImageComponent?: React.ComponentType<any>;
9+
ImageComponent?: React.ComponentType<ImageProps>;
1010
};
1111

1212
export const GalleryImageWithContext = (props: GalleryImageWithContextProps) => {

package/src/components/Attachment/Giphy/GiphyImage.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from 'react';
2-
import { Image, StyleSheet, View } from 'react-native';
2+
import { Image, ImageProps, StyleSheet, View } from 'react-native';
33

44
import type { Attachment } from 'stream-chat';
55

@@ -16,14 +16,14 @@ import { makeImageCompatibleUrl } from '../../../utils/utils';
1616
import { GiphyBadge } from '../../ui/Badge/GiphyBadge';
1717

1818
export type GiphyImagePropsWithContext = Pick<MessagesContextValue, 'giphyVersion'> & {
19-
ImageComponent?: React.ComponentType<any>;
20-
} & {
21-
attachment: Attachment;
22-
/**
23-
* Whether to render the preview image or the full image
24-
*/
25-
preview?: boolean;
26-
};
19+
ImageComponent?: React.ComponentType<ImageProps>;
20+
} & {
21+
attachment: Attachment;
22+
/**
23+
* Whether to render the preview image or the full image
24+
*/
25+
preview?: boolean;
26+
};
2727

2828
const GiphyImageWithContext = (props: GiphyImagePropsWithContext) => {
2929
const { attachment, giphyVersion, ImageComponent = Image, preview = false } = props;

package/src/components/Attachment/UrlPreview/URLPreview.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useMemo } from 'react';
22
import {
33
Image,
4+
ImageProps,
45
ImageStyle,
56
Pressable,
67
StyleProp,
@@ -32,8 +33,9 @@ import { VideoPlayIndicator } from '../../ui';
3233
import { ImageBackground } from '../../UIComponents/ImageBackground';
3334
import { openUrlSafely } from '../utils/openUrlSafely';
3435

35-
export type URLPreviewPropsWithContext = { ImageComponent?: React.ComponentType<any> } &
36-
Pick<MessageContextValue, 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> &
36+
export type URLPreviewPropsWithContext = {
37+
ImageComponent?: React.ComponentType<ImageProps>;
38+
} & Pick<MessageContextValue, 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> &
3739
Pick<
3840
MessagesContextValue,
3941
'additionalPressableProps' | 'myMessageTheme' | 'isAttachmentEqual'

package/src/components/Attachment/UrlPreview/URLPreviewCompact.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useMemo } from 'react';
22
import {
33
Image,
4+
ImageProps,
45
ImageStyle,
56
Pressable,
67
StyleProp,
@@ -32,8 +33,9 @@ import { VideoPlayIndicator } from '../../ui';
3233
import { ImageBackground } from '../../UIComponents/ImageBackground';
3334
import { openUrlSafely } from '../utils/openUrlSafely';
3435

35-
export type URLPreviewCompactPropsWithContext = { ImageComponent?: React.ComponentType<any> } &
36-
Pick<MessageContextValue, 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> &
36+
export type URLPreviewCompactPropsWithContext = {
37+
ImageComponent?: React.ComponentType<ImageProps>;
38+
} & Pick<MessageContextValue, 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> &
3739
Pick<MessagesContextValue, 'additionalPressableProps' | 'myMessageTheme'> & {
3840
attachment: Attachment;
3941
channelId: string | undefined;

package/src/components/ImageGallery/ImageGallery.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@ import Animated, {
1313

1414
import { AnimatedGalleryImage } from './components/AnimatedGalleryImage';
1515
import { AnimatedGalleryVideo } from './components/AnimatedGalleryVideo';
16+
import type {
17+
ImageGalleryFooterProps,
18+
ImageGalleryGridProps,
19+
ImageGalleryHeaderProps,
20+
} from './components/types';
1621

1722
import { useImageGalleryGestures } from './hooks/useImageGalleryGestures';
1823

24+
import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext';
1925
import {
2026
ImageGalleryProviderProps,
2127
useImageGalleryContext,
2228
} from '../../contexts/imageGalleryContext/ImageGalleryContext';
23-
import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext';
2429
import {
2530
OverlayContextValue,
2631
useOverlayContext,
@@ -67,9 +72,9 @@ type ImageGalleryWithContextProps = Pick<
6772
'numberOfImageGalleryGridColumns'
6873
> &
6974
Pick<OverlayContextValue, 'overlayOpacity'> & {
70-
ImageGalleryHeader?: React.ComponentType<any>;
71-
ImageGalleryFooter?: React.ComponentType<any>;
72-
ImageGalleryGrid?: React.ComponentType<any>;
75+
ImageGalleryHeader?: React.ComponentType<ImageGalleryHeaderProps>;
76+
ImageGalleryFooter?: React.ComponentType<ImageGalleryFooterProps>;
77+
ImageGalleryGrid?: React.ComponentType<ImageGalleryGridProps>;
7378
};
7479

7580
export const ImageGalleryWithContext = (props: ImageGalleryWithContextProps) => {
@@ -370,11 +375,7 @@ export type ImageGalleryProps = Partial<ImageGalleryWithContextProps>;
370375

371376
export const ImageGallery = (props: ImageGalleryProps) => {
372377
const { numberOfImageGalleryGridColumns } = useImageGalleryContext();
373-
const {
374-
ImageGalleryHeader,
375-
ImageGalleryFooter,
376-
ImageGalleryGrid,
377-
} = useComponentsContext();
378+
const { ImageGalleryHeader, ImageGalleryFooter, ImageGalleryGrid } = useComponentsContext();
378379
const { overlayOpacity } = useOverlayContext();
379380
return (
380381
<ImageGalleryWithContext

package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const ImageGalleryComponentVideo = (props: ImageGalleryProps) => {
6060

6161
return (
6262
<OverlayProvider value={{ overlayOpacity: { value: 1 } as SharedValue<number> }}>
63+
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
6364
<WithComponents overrides={{ ImageGalleryHeader: undefined as any }}>
6465
<ImageGalleryContext.Provider
6566
value={
@@ -101,6 +102,7 @@ const ImageGalleryComponentImage = (
101102

102103
return (
103104
<OverlayProvider value={{ overlayOpacity: { value: 1 } as SharedValue<number> }}>
105+
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
104106
<WithComponents overrides={{ ImageGalleryHeader: undefined as any }}>
105107
<ImageGalleryContext.Provider
106108
value={

package/src/components/Reply/Reply.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import React, { useMemo } from 'react';
2-
import { I18nManager, Image, StyleSheet, Text, TextStyle, View, ViewStyle } from 'react-native';
2+
import {
3+
I18nManager,
4+
Image,
5+
ImageProps,
6+
StyleSheet,
7+
Text,
8+
TextStyle,
9+
View,
10+
ViewStyle,
11+
} from 'react-native';
312

413
import {
514
isFileAttachment,
@@ -79,8 +88,10 @@ const RightContent = React.memo(
7988
},
8089
);
8190

82-
export type ReplyPropsWithContext = { ImageComponent?: React.ComponentType<any> } &
83-
Pick<MessageContextValue, 'message'> &
91+
export type ReplyPropsWithContext = { ImageComponent: React.ComponentType<ImageProps> } & Pick<
92+
MessageContextValue,
93+
'message'
94+
> &
8495
Pick<MessagesContextValue, 'quotedMessage'> & {
8596
isMyMessage: boolean;
8697
onDismiss?: () => void;

package/src/contexts/componentsContext/defaultComponents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import { ChannelPreviewUnreadCount } from '../../components/ChannelPreview/Chann
4040
import { ChannelPreviewView } from '../../components/ChannelPreview/ChannelPreviewView';
4141
import { ImageGalleryFooter } from '../../components/ImageGallery/components/ImageGalleryFooter';
4242
import { ImageGalleryHeader } from '../../components/ImageGallery/components/ImageGalleryHeader';
43-
import { ImageGalleryGrid } from '../../components/ImageGallery/components/ImageGrid';
4443
import { ImageGalleryVideoControl } from '../../components/ImageGallery/components/ImageGalleryVideoControl';
44+
import { ImageGalleryGrid } from '../../components/ImageGallery/components/ImageGrid';
4545
import { EmptyStateIndicator } from '../../components/Indicators/EmptyStateIndicator';
4646
import { LoadingErrorIndicator } from '../../components/Indicators/LoadingErrorIndicator';
4747
import { LoadingIndicator } from '../../components/Indicators/LoadingIndicator';
@@ -299,6 +299,7 @@ export const DEFAULT_COMPONENTS = {
299299
MessageOverlayBackground: DefaultMessageOverlayBackground,
300300

301301
// Image
302+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
302303
ImageComponent: Image as React.ComponentType<any>,
303304

304305
// Optional overrides (no defaults — undefined unless user provides via WithComponents)

0 commit comments

Comments
 (0)