Skip to content

Commit 7ddf882

Browse files
authored
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
1 parent 895b433 commit 7ddf882

File tree

22 files changed

+98
-82
lines changed

22 files changed

+98
-82
lines changed

components/_util/colors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const PresetStatusColorTypes = [
1414

1515
export type PresetColorType = PresetColorKey | InverseColor;
1616

17-
export type PresetStatusColorType = typeof PresetStatusColorTypes[number];
17+
export type PresetStatusColorType = (typeof PresetStatusColorTypes)[number];
1818

1919
/**
2020
* determine if the color keyword belongs to the `Ant Design` {@link PresetColors}.

components/_util/statusUtils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from './classNames';
33

44
const InputStatuses = ['warning', 'error', ''] as const;
55

6-
export type InputStatus = typeof InputStatuses[number];
6+
export type InputStatus = (typeof InputStatuses)[number];
77

88
export function getStatusClassNames(
99
prefixCls: string,

components/_util/transition.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { nextTick, Transition, TransitionGroup } from 'vue';
99
import { tuple } from './type';
1010

1111
const SelectPlacements = tuple('bottomLeft', 'bottomRight', 'topLeft', 'topRight');
12-
export type SelectCommonPlacement = typeof SelectPlacements[number];
12+
export type SelectCommonPlacement = (typeof SelectPlacements)[number];
1313

1414
const getTransitionDirection = (placement: SelectCommonPlacement | undefined) => {
1515
if (placement !== undefined && (placement === 'topLeft' || placement === 'topRight')) {

components/alert/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const iconMapOutlined = {
3535

3636
const AlertTypes = tuple('success', 'info', 'warning', 'error');
3737

38-
export type AlertType = typeof AlertTypes[number];
38+
export type AlertType = (typeof AlertTypes)[number];
3939

4040
export const alertProps = () => ({
4141
/**

components/config-provider/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ function getGlobalIconPrefixCls() {
4444
return globalConfigForApi.iconPrefixCls || defaultIconPrefixCls;
4545
}
4646
const globalConfigBySet = reactive<ConfigProviderProps>({}); // 权重最大
47-
export const globalConfigForApi = reactive<
48-
ConfigProviderProps & {
49-
getRootPrefixCls?: (rootPrefixCls?: string, customizePrefixCls?: string) => string;
50-
}
51-
>({});
47+
export const globalConfigForApi: ConfigProviderProps & {
48+
getRootPrefixCls?: (rootPrefixCls?: string, customizePrefixCls?: string) => string;
49+
} = reactive({});
5250

5351
export const configConsumerProps = [
5452
'getTargetContainer',

components/date-picker/__tests__/other.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { asyncExpect, sleep } from '../../../tests/utils';
33
import dayjs from 'dayjs';
44
import DatePicker from '../';
55
import LocaleProvider from '../../locale-provider';
6-
import locale from '../../locale-provider/zh_CN';
6+
import locale from '../../locale/zh_CN';
77
jest.mock('../../_util/Portal');
88
const { MonthPicker, WeekPicker } = DatePicker;
99

components/drawer/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import type { KeyboardEventHandler, MouseEventHandler } from '../_util/EventInte
2424
type ILevelMove = number | [number, number];
2525

2626
const PlacementTypes = tuple('top', 'right', 'bottom', 'left');
27-
export type placementType = typeof PlacementTypes[number];
27+
export type placementType = (typeof PlacementTypes)[number];
2828

2929
const SizeTypes = tuple('default', 'large');
30-
export type sizeType = typeof SizeTypes[number];
30+
export type sizeType = (typeof SizeTypes)[number];
3131

3232
export interface PushState {
3333
distance: string | number;

components/form/Form.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {
2424
Callbacks,
2525
ValidateMessages,
2626
Rule,
27+
FormLabelAlign,
2728
} from './interface';
2829
import useConfigInject from '../config-provider/hooks/useConfigInject';
2930
import { useProvideForm } from './context';
@@ -42,7 +43,10 @@ export const formProps = () => ({
4243
labelCol: { type: Object as PropType<ColProps & HTMLAttributes> },
4344
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
4445
colon: { type: Boolean, default: undefined },
45-
labelAlign: PropTypes.oneOf(tuple('left', 'right')),
46+
labelAlign: {
47+
...PropTypes.oneOf(tuple('left', 'right')),
48+
type: String as PropType<FormLabelAlign>,
49+
},
4650
labelWrap: { type: Boolean, default: undefined },
4751
prefixCls: String,
4852
requiredMark: { type: [String, Boolean] as PropType<RequiredMark | ''>, default: undefined },

components/form/FormItem.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ import { toArray } from './utils/typeUtil';
3232
import { warning } from '../vc-util/warning';
3333
import find from 'lodash-es/find';
3434
import { tuple } from '../_util/type';
35-
import type { InternalNamePath, Rule, RuleError, RuleObject, ValidateOptions } from './interface';
35+
import type {
36+
InternalNamePath,
37+
Rule,
38+
RuleError,
39+
RuleObject,
40+
ValidateOptions,
41+
FormLabelAlign,
42+
} from './interface';
3643
import useConfigInject from '../config-provider/hooks/useConfigInject';
3744
import { useInjectForm } from './context';
3845
import FormItemLabel from './FormItemLabel';
@@ -44,7 +51,7 @@ import useDebounce from './utils/useDebounce';
4451
import classNames from '../_util/classNames';
4552

4653
const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '');
47-
export type ValidateStatus = typeof ValidateStatuses[number];
54+
export type ValidateStatus = (typeof ValidateStatuses)[number];
4855

4956
export interface FieldExpose {
5057
fieldValue: Ref<any>;
@@ -105,7 +112,10 @@ export const formItemProps = () => ({
105112
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
106113
hasFeedback: { type: Boolean, default: false },
107114
colon: { type: Boolean, default: undefined },
108-
labelAlign: PropTypes.oneOf(tuple('left', 'right')),
115+
labelAlign: {
116+
...PropTypes.oneOf(tuple('left', 'right')),
117+
type: String as PropType<FormLabelAlign>,
118+
},
109119
prop: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
110120
name: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
111121
rules: [Array, Object] as PropType<Rule[] | Rule>,

components/grid/demo/use-breakpoint.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Use `useBreakpoint` Hook provide personalized layout.
1919
<template>
2020
Current break point:
2121
<template v-for="(value, key) in screens">
22-
<a-tag v-if="!!value" color="blue" :key="key">
22+
<a-tag v-if="!!value" :key="key" color="blue">
2323
{{ key }}
2424
</a-tag>
2525
</template>

0 commit comments

Comments
 (0)