From dbf8027c2d9b538694ffd5889ba9f4010d93fb6a Mon Sep 17 00:00:00 2001 From: Jungzl <13jungzl@gmail.com> Date: Wed, 10 Jan 2024 10:20:28 +0800 Subject: [PATCH] fix(Image): ImagePosition type is not exported before (#12549) --- packages/vant/package.json | 1 + packages/vant/src/image/Image.tsx | 11 ++--------- packages/vant/src/image/index.ts | 4 ++-- packages/vant/src/image/types.ts | 6 ++++++ packages/vant/tsconfig.json | 2 +- pnpm-lock.yaml | 3 +++ 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/vant/package.json b/packages/vant/package.json index 9d90324d9..c7516a7b2 100644 --- a/packages/vant/package.json +++ b/packages/vant/package.json @@ -64,6 +64,7 @@ "@vitest/coverage-istanbul": "^1.1.3", "@vue/runtime-core": "^3.4.0-rc.1", "@vue/test-utils": "^2.3.2", + "csstype": "^3.1.3", "diffable-html": "^5.0.0", "jsdom": "^22.1.0", "typescript": "^5.0.4", diff --git a/packages/vant/src/image/Image.tsx b/packages/vant/src/image/Image.tsx index 0589a718d..513167a20 100644 --- a/packages/vant/src/image/Image.tsx +++ b/packages/vant/src/image/Image.tsx @@ -29,15 +29,8 @@ import { Icon } from '../icon'; const [name, bem] = createNamespace('image'); -export type ImageFit = 'contain' | 'cover' | 'fill' | 'none' | 'scale-down'; - -export type ImagePosition = - | 'center' - | 'top' - | 'right' - | 'bottom' - | 'left' - | string; +// Types +import type { ImageFit, ImagePosition } from './types'; export const imageProps = { src: String, diff --git a/packages/vant/src/image/index.ts b/packages/vant/src/image/index.ts index 40f56ddb3..2b94527b2 100644 --- a/packages/vant/src/image/index.ts +++ b/packages/vant/src/image/index.ts @@ -4,8 +4,8 @@ import _Image from './Image'; export const Image = withInstall(_Image); export default Image; export { imageProps } from './Image'; -export type { ImageFit, ImageProps } from './Image'; -export type { ImageThemeVars } from './types'; +export type { ImageProps } from './Image'; +export type { ImageFit, ImagePosition, ImageThemeVars } from './types'; declare module 'vue' { export interface GlobalComponents { diff --git a/packages/vant/src/image/types.ts b/packages/vant/src/image/types.ts index 659294c45..aafdf4f0d 100644 --- a/packages/vant/src/image/types.ts +++ b/packages/vant/src/image/types.ts @@ -1,3 +1,9 @@ +import type { CSSProperties } from 'vue'; + +export type ImageFit = CSSProperties['objectFit']; + +export type ImagePosition = CSSProperties['objectPosition']; + export type ImageThemeVars = { imagePlaceholderTextColor?: string; imagePlaceholderFontSize?: string; diff --git a/packages/vant/tsconfig.json b/packages/vant/tsconfig.json index 80de9a67b..3d9db7fdf 100644 --- a/packages/vant/tsconfig.json +++ b/packages/vant/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "allowJs": true, "noImplicitThis": true, - "types": ["vitest/globals", "vue/jsx"] + "types": ["vitest/globals", "vue/jsx", "csstype"] }, "include": ["src/**/*", "docs/**/*", "test/**/*"], "exclude": ["**/node_modules", "**/.*/"] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38a668842..bd2651340 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -100,6 +100,9 @@ importers: '@vue/test-utils': specifier: ^2.3.2 version: 2.4.1(vue@3.4.0-rc.1) + csstype: + specifier: ^3.1.3 + version: 3.1.3 diffable-html: specifier: ^5.0.0 version: 5.0.0