From 7ddf882a99f33ca9534087cb1c70ec225ba4549f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=9C=E5=86=BB=E6=A9=99?= Date: Fri, 17 Feb 2023 22:01:30 +0800 Subject: [PATCH] Feat v4 fix type errors (#6285) * fix compile type errors * fix menuprops type import * fix lint errors * fix lint errors * fix format error * fix node version * fix run dist error * fix run lint * fix as any * fix string type --- components/_util/colors.ts | 2 +- components/_util/statusUtils.tsx | 2 +- components/_util/transition.tsx | 2 +- components/alert/index.tsx | 2 +- components/config-provider/index.tsx | 8 +- .../date-picker/__tests__/other.test.js | 2 +- components/drawer/index.tsx | 4 +- components/form/Form.tsx | 6 +- components/form/FormItem.tsx | 16 ++- components/grid/demo/use-breakpoint.vue | 2 +- .../locale-provider/__tests__/index.test.js | 102 +++++++++--------- components/mentions/index.tsx | 2 +- components/menu/src/OverrideContext.ts | 2 +- components/radio/Group.tsx | 2 +- components/skeleton/Skeleton.tsx | 6 +- components/table/index.tsx | 4 +- .../theme/util/genComponentStyleHook.ts | 2 +- components/tree/index.tsx | 6 +- .../vc-picker/panels/DatetimePanel/index.tsx | 2 +- components/vc-select/BaseSelect.tsx | 2 +- components/vc-select/utils/valueUtil.ts | 2 +- webpack.build.conf.js | 2 +- 22 files changed, 98 insertions(+), 82 deletions(-) diff --git a/components/_util/colors.ts b/components/_util/colors.ts index 7d87054c2..8bb5a90ab 100644 --- a/components/_util/colors.ts +++ b/components/_util/colors.ts @@ -14,7 +14,7 @@ export const PresetStatusColorTypes = [ export type PresetColorType = PresetColorKey | InverseColor; -export type PresetStatusColorType = typeof PresetStatusColorTypes[number]; +export type PresetStatusColorType = (typeof PresetStatusColorTypes)[number]; /** * determine if the color keyword belongs to the `Ant Design` {@link PresetColors}. diff --git a/components/_util/statusUtils.tsx b/components/_util/statusUtils.tsx index 491d256fb..a9cb68aaa 100644 --- a/components/_util/statusUtils.tsx +++ b/components/_util/statusUtils.tsx @@ -3,7 +3,7 @@ import classNames from './classNames'; const InputStatuses = ['warning', 'error', ''] as const; -export type InputStatus = typeof InputStatuses[number]; +export type InputStatus = (typeof InputStatuses)[number]; export function getStatusClassNames( prefixCls: string, diff --git a/components/_util/transition.tsx b/components/_util/transition.tsx index f0fe0eb18..84f454022 100644 --- a/components/_util/transition.tsx +++ b/components/_util/transition.tsx @@ -9,7 +9,7 @@ import { nextTick, Transition, TransitionGroup } from 'vue'; import { tuple } from './type'; const SelectPlacements = tuple('bottomLeft', 'bottomRight', 'topLeft', 'topRight'); -export type SelectCommonPlacement = typeof SelectPlacements[number]; +export type SelectCommonPlacement = (typeof SelectPlacements)[number]; const getTransitionDirection = (placement: SelectCommonPlacement | undefined) => { if (placement !== undefined && (placement === 'topLeft' || placement === 'topRight')) { diff --git a/components/alert/index.tsx b/components/alert/index.tsx index af1ea1217..68dba0a25 100644 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -35,7 +35,7 @@ const iconMapOutlined = { const AlertTypes = tuple('success', 'info', 'warning', 'error'); -export type AlertType = typeof AlertTypes[number]; +export type AlertType = (typeof AlertTypes)[number]; export const alertProps = () => ({ /** diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index 7476a2ef6..13e847d94 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -44,11 +44,9 @@ function getGlobalIconPrefixCls() { return globalConfigForApi.iconPrefixCls || defaultIconPrefixCls; } const globalConfigBySet = reactive({}); // 权重最大 -export const globalConfigForApi = reactive< - ConfigProviderProps & { - getRootPrefixCls?: (rootPrefixCls?: string, customizePrefixCls?: string) => string; - } ->({}); +export const globalConfigForApi: ConfigProviderProps & { + getRootPrefixCls?: (rootPrefixCls?: string, customizePrefixCls?: string) => string; +} = reactive({}); export const configConsumerProps = [ 'getTargetContainer', diff --git a/components/date-picker/__tests__/other.test.js b/components/date-picker/__tests__/other.test.js index 4ec54f861..e88b7f5ab 100644 --- a/components/date-picker/__tests__/other.test.js +++ b/components/date-picker/__tests__/other.test.js @@ -3,7 +3,7 @@ import { asyncExpect, sleep } from '../../../tests/utils'; import dayjs from 'dayjs'; import DatePicker from '../'; import LocaleProvider from '../../locale-provider'; -import locale from '../../locale-provider/zh_CN'; +import locale from '../../locale/zh_CN'; jest.mock('../../_util/Portal'); const { MonthPicker, WeekPicker } = DatePicker; diff --git a/components/drawer/index.tsx b/components/drawer/index.tsx index ca4ccd942..984cb7be2 100644 --- a/components/drawer/index.tsx +++ b/components/drawer/index.tsx @@ -24,10 +24,10 @@ import type { KeyboardEventHandler, MouseEventHandler } from '../_util/EventInte type ILevelMove = number | [number, number]; const PlacementTypes = tuple('top', 'right', 'bottom', 'left'); -export type placementType = typeof PlacementTypes[number]; +export type placementType = (typeof PlacementTypes)[number]; const SizeTypes = tuple('default', 'large'); -export type sizeType = typeof SizeTypes[number]; +export type sizeType = (typeof SizeTypes)[number]; export interface PushState { distance: string | number; diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 5576d3ebb..a24b06f3a 100755 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -24,6 +24,7 @@ import type { Callbacks, ValidateMessages, Rule, + FormLabelAlign, } from './interface'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { useProvideForm } from './context'; @@ -42,7 +43,10 @@ export const formProps = () => ({ labelCol: { type: Object as PropType }, wrapperCol: { type: Object as PropType }, colon: { type: Boolean, default: undefined }, - labelAlign: PropTypes.oneOf(tuple('left', 'right')), + labelAlign: { + ...PropTypes.oneOf(tuple('left', 'right')), + type: String as PropType, + }, labelWrap: { type: Boolean, default: undefined }, prefixCls: String, requiredMark: { type: [String, Boolean] as PropType, default: undefined }, diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index f5f956ae8..293b05157 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -32,7 +32,14 @@ import { toArray } from './utils/typeUtil'; import { warning } from '../vc-util/warning'; import find from 'lodash-es/find'; import { tuple } from '../_util/type'; -import type { InternalNamePath, Rule, RuleError, RuleObject, ValidateOptions } from './interface'; +import type { + InternalNamePath, + Rule, + RuleError, + RuleObject, + ValidateOptions, + FormLabelAlign, +} from './interface'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { useInjectForm } from './context'; import FormItemLabel from './FormItemLabel'; @@ -44,7 +51,7 @@ import useDebounce from './utils/useDebounce'; import classNames from '../_util/classNames'; const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', ''); -export type ValidateStatus = typeof ValidateStatuses[number]; +export type ValidateStatus = (typeof ValidateStatuses)[number]; export interface FieldExpose { fieldValue: Ref; @@ -105,7 +112,10 @@ export const formItemProps = () => ({ wrapperCol: { type: Object as PropType }, hasFeedback: { type: Boolean, default: false }, colon: { type: Boolean, default: undefined }, - labelAlign: PropTypes.oneOf(tuple('left', 'right')), + labelAlign: { + ...PropTypes.oneOf(tuple('left', 'right')), + type: String as PropType, + }, prop: { type: [String, Number, Array] as PropType> }, name: { type: [String, Number, Array] as PropType> }, rules: [Array, Object] as PropType, diff --git a/components/grid/demo/use-breakpoint.vue b/components/grid/demo/use-breakpoint.vue index ebe90e330..b671da17d 100644 --- a/components/grid/demo/use-breakpoint.vue +++ b/components/grid/demo/use-breakpoint.vue @@ -19,7 +19,7 @@ Use `useBreakpoint` Hook provide personalized layout.