Skip to content

Commit 8c1979e

Browse files
committed
fix: image type error #4185
1 parent 6ae707e commit 8c1979e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

components/image/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { App, defineComponent, inject, Plugin } from 'vue';
1+
import { App, defineComponent, ExtractPropTypes, ImgHTMLAttributes, inject, Plugin } from 'vue';
22
import { defaultConfigProvider } from '../config-provider';
33
import ImageInternal from '../vc-image';
4-
import { ImageProps, ImagePropsType } from '../vc-image/src/Image';
5-
4+
import { imageProps } from '../vc-image/src/Image';
65
import PreviewGroup from './PreviewGroup';
7-
const Image = defineComponent({
6+
7+
export type ImageProps = Partial<
8+
ExtractPropTypes<typeof imageProps> & Omit<ImgHTMLAttributes, 'placeholder' | 'onClick'>
9+
>;
10+
const Image = defineComponent<ImageProps>({
811
name: 'AImage',
912
inheritAttrs: false,
10-
props: ImageProps,
13+
props: imageProps as any,
1114
setup(props, ctx) {
1215
const { slots, attrs } = ctx;
1316
const configProvider = inject('configProvider', defaultConfigProvider);
@@ -19,7 +22,7 @@ const Image = defineComponent({
1922
},
2023
});
2124

22-
export { ImageProps, ImagePropsType };
25+
export { imageProps };
2326

2427
Image.PreviewGroup = PreviewGroup;
2528

components/vc-image/src/Image.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface ImagePropsType extends Omit<ImgHTMLAttributes, 'placeholder' |
3636
fallback?: string;
3737
preview?: boolean | ImagePreviewType;
3838
}
39-
export const ImageProps = {
39+
export const imageProps = {
4040
src: PropTypes.string,
4141
wrapperClassName: PropTypes.string,
4242
wrapperStyle: PropTypes.style,
@@ -69,7 +69,7 @@ const ImageInternal = defineComponent({
6969
name: 'Image',
7070
mixins: [BaseMixin],
7171
inheritAttrs: false,
72-
props: ImageProps,
72+
props: imageProps,
7373
emits: ['click'],
7474
setup(props, { attrs, slots, emit }) {
7575
const prefixCls = computed(() => props.prefixCls);

0 commit comments

Comments
 (0)