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>

components/locale-provider/__tests__/index.test.js

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,57 @@ import {
1414
Transfer,
1515
} from '../..';
1616
import LocaleProvider from '..';
17-
import arEG from '../ar_EG';
18-
import bgBG from '../bg_BG';
19-
import caES from '../ca_ES';
20-
import csCZ from '../cs_CZ';
21-
import daDK from '../da_DK';
22-
import deDE from '../de_DE';
23-
import elGR from '../el_GR';
24-
import enGB from '../en_GB';
25-
import enUS from '../en_US';
26-
import esES from '../es_ES';
27-
import etEE from '../et_EE';
28-
import faIR from '../fa_IR';
29-
import fiFI from '../fi_FI';
30-
import frBE from '../fr_BE';
31-
import frFR from '../fr_FR';
32-
import heIL from '../he_IL';
33-
import hiIN from '../hi_IN';
34-
import hrHR from '../hr_HR';
35-
import huHU from '../hu_HU';
36-
import hyAM from '../hy_AM';
37-
import isIS from '../is_IS';
38-
import itIT from '../it_IT';
39-
import jaJP from '../ja_JP';
40-
import knIN from '../kn_IN';
41-
import koKR from '../ko_KR';
42-
import kuIQ from '../ku_IQ';
43-
import mkMK from '../mk_MK';
44-
import mnMN from '../mn_MN';
45-
import msMY from '../ms_MY';
46-
import nbNO from '../nb_NO';
47-
import neNP from '../ne-NP';
48-
import nlBE from '../nl_BE';
49-
import nlNL from '../nl_NL';
50-
import plPL from '../pl_PL';
51-
import ptBR from '../pt_BR';
52-
import ptPT from '../pt_PT';
53-
import roRO from '../ro_RO';
54-
import ruRU from '../ru_RU';
55-
import skSK from '../sk_SK';
56-
import slSI from '../sl_SI';
57-
import srRS from '../sr_RS';
58-
import svSE from '../sv_SE';
59-
import taIN from '../ta_IN';
60-
import thTH from '../th_TH';
61-
import trTR from '../tr_TR';
62-
import ukUA from '../uk_UA';
63-
import viVN from '../vi_VN';
64-
import idID from '../id_ID';
65-
import lvLV from '../lv_LV';
66-
import zhCN from '../zh_CN';
67-
import zhTW from '../zh_TW';
17+
import arEG from '../../locale/ar_EG';
18+
import bgBG from '../../locale/bg_BG';
19+
import caES from '../../locale/ca_ES';
20+
import csCZ from '../../locale/cs_CZ';
21+
import daDK from '../../locale/da_DK';
22+
import deDE from '../../locale/de_DE';
23+
import elGR from '../../locale/el_GR';
24+
import enGB from '../../locale/en_GB';
25+
import enUS from '../../locale/en_US';
26+
import esES from '../../locale/es_ES';
27+
import etEE from '../../locale/et_EE';
28+
import faIR from '../../locale/fa_IR';
29+
import fiFI from '../../locale/fi_FI';
30+
import frBE from '../../locale/fr_BE';
31+
import frFR from '../../locale/fr_FR';
32+
import heIL from '../../locale/he_IL';
33+
import hiIN from '../../locale/hi_IN';
34+
import hrHR from '../../locale/hr_HR';
35+
import huHU from '../../locale/hu_HU';
36+
import hyAM from '../../locale/hy_AM';
37+
import isIS from '../../locale/is_IS';
38+
import itIT from '../../locale/it_IT';
39+
import jaJP from '../../locale/ja_JP';
40+
import knIN from '../../locale/kn_IN';
41+
import koKR from '../../locale/ko_KR';
42+
import kuIQ from '../../locale/ku_IQ';
43+
import mkMK from '../../locale/mk_MK';
44+
import mnMN from '../../locale/mn_MN';
45+
import msMY from '../../locale/ms_MY';
46+
import nbNO from '../../locale/nb_NO';
47+
import neNP from '../../locale/ne_NP';
48+
import nlBE from '../../locale/nl_BE';
49+
import nlNL from '../../locale/nl_NL';
50+
import plPL from '../../locale/pl_PL';
51+
import ptBR from '../../locale/pt_BR';
52+
import ptPT from '../../locale/pt_PT';
53+
import roRO from '../../locale/ro_RO';
54+
import ruRU from '../../locale/ru_RU';
55+
import skSK from '../../locale/sk_SK';
56+
import slSI from '../../locale/sl_SI';
57+
import srRS from '../../locale/sr_RS';
58+
import svSE from '../../locale/sv_SE';
59+
import taIN from '../../locale/ta_IN';
60+
import thTH from '../../locale/th_TH';
61+
import trTR from '../../locale/tr_TR';
62+
import ukUA from '../../locale/uk_UA';
63+
import viVN from '../../locale/vi_VN';
64+
import idID from '../../locale/id_ID';
65+
import lvLV from '../../locale/lv_LV';
66+
import zhCN from '../../locale/zh_CN';
67+
import zhTW from '../../locale/zh_TW';
6868

6969
const locales = [
7070
arEG,

components/mentions/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ const Mentions = defineComponent({
279279
/* istanbul ignore next */
280280
export const MentionsOption = defineComponent({
281281
compatConfig: { MODE: 3 },
282-
...Option,
282+
...(Option as any),
283283
name: 'AMentionsOption',
284284
props: optionProps,
285285
});

components/menu/src/OverrideContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ComputedRef, InjectionKey } from 'vue';
22
import { provide, computed, inject } from 'vue';
3-
import type { MenuProps } from './menu';
3+
import type { MenuProps } from './Menu';
44

55
// Used for Dropdown only
66
export interface OverrideContextProps {

components/radio/Group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useProvideRadioGroupContext } from './context';
1111

1212
const RadioGroupSizeTypes = tuple('large', 'default', 'small');
1313

14-
export type RadioGroupSize = typeof RadioGroupSizeTypes[number];
14+
export type RadioGroupSize = (typeof RadioGroupSizeTypes)[number];
1515

1616
export type RadioGroupOption = RadioGroupOptionType;
1717

components/skeleton/Skeleton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ const Skeleton = defineComponent({
9696
const { loading, avatar, title, paragraph, active, round } = props;
9797
const pre = prefixCls.value;
9898
if (loading || props.loading === undefined) {
99-
const hasAvatar = !!avatar || avatar === '';
100-
const hasTitle = !!title || title === '';
101-
const hasParagraph = !!paragraph || paragraph === '';
99+
const hasAvatar = !!avatar || (avatar as string) === '';
100+
const hasTitle = !!title || (title as string) === '';
101+
const hasParagraph = !!paragraph || (paragraph as string) === '';
102102

103103
// Avatar
104104
let avatarNode;

components/table/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export type { ColumnProps } from './Column';
1616
export type { ColumnsType, ColumnType, ColumnGroupType } from './interface';
1717
export type { TableProps, TablePaginationConfig };
1818

19-
const TableSummaryRow = defineComponent({ ...SummaryRow, name: 'ATableSummaryRow' });
20-
const TableSummaryCell = defineComponent({ ...SummaryCell, name: 'ATableSummaryCell' });
19+
const TableSummaryRow = defineComponent({ ...(SummaryRow as any), name: 'ATableSummaryRow' });
20+
const TableSummaryCell = defineComponent({ ...(SummaryCell as any), name: 'ATableSummaryCell' });
2121

2222
const TableSummary = Object.assign(Summary, {
2323
Cell: TableSummaryCell,

components/theme/util/genComponentStyleHook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { genCommonStyle, genLinkStyle } from '../../_style';
66
import type { UseComponentStyleResult } from '../internal';
77
import { mergeToken, statisticToken, useToken } from '../internal';
88
import type { ComponentTokenMap, GlobalToken } from '../interface';
9-
import useConfigInject from 'ant-design-vue/es/config-provider/hooks/useConfigInject';
9+
import useConfigInject from '../../config-provider/hooks/useConfigInject';
1010
import type { Ref } from 'vue';
1111
import { computed } from 'vue';
1212

components/tree/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export type {
2626

2727
/* istanbul ignore next */
2828

29-
const TreeNode = defineComponent({ ...VcTreeNode, name: 'ATreeNode', props: treeNodeProps });
29+
const TreeNode = defineComponent({
30+
...(VcTreeNode as any),
31+
name: 'ATreeNode',
32+
props: treeNodeProps,
33+
});
3034

3135
export { DirectoryTree, TreeNode };
3236

components/vc-picker/panels/DatetimePanel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type DatetimePanelProps<DateType> = {
1717
} & Omit<DatePanelProps<DateType>, 'disabledHours' | 'disabledMinutes' | 'disabledSeconds'>;
1818

1919
const ACTIVE_PANEL = tuple('date', 'time');
20-
type ActivePanelType = typeof ACTIVE_PANEL[number];
20+
type ActivePanelType = (typeof ACTIVE_PANEL)[number];
2121

2222
function DatetimePanel<DateType>(_props: DatetimePanelProps<DateType>) {
2323
const props = useMergeProps(_props);

components/vc-select/BaseSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ export default defineComponent({
700700
typeof getRawInputElement === 'function' && getRawInputElement();
701701
const domProps = {
702702
...restProps,
703-
} as Omit<keyof typeof restProps, typeof DEFAULT_OMIT_PROPS[number]>;
703+
} as Omit<keyof typeof restProps, (typeof DEFAULT_OMIT_PROPS)[number]>;
704704

705705
// Used for raw custom input trigger
706706
let onTriggerVisibleChange: null | ((newOpen: boolean) => void);

components/vc-select/utils/valueUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function flattenOptions<OptionType extends BaseOptionType = DefaultOption
8686
/**
8787
* Inject `props` into `option` for legacy usage
8888
*/
89-
export function injectPropsWithOption<T>(option: T): T {
89+
export function injectPropsWithOption<T extends object>(option: T): T {
9090
const newOption = { ...option };
9191
if (!('props' in newOption)) {
9292
Object.defineProperty(newOption, 'props', {

webpack.build.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function externalDayjs(config) {
5252
});
5353
config.externals.push(function ({ _context, request }, callback) {
5454
if (/^dayjs\/plugin\//.test(request)) {
55-
const name = request.replaceAll('/', '_');
55+
const name = request.replace(/\//g, '_');
5656
return callback(null, {
5757
root: name,
5858
commonjs2: name,

0 commit comments

Comments
 (0)