chore: update changelog

This commit is contained in:
期贤 2023-10-23 17:57:52 +08:00
parent 24cf79956f
commit 6d88f95055
107 changed files with 1347 additions and 1035 deletions

View File

@ -15,7 +15,7 @@ const alias = pkgList.reduce((pre, pkg) => {
return {
...pre,
};
}, {});
}, {} as Record<string, string>);
console.log(`🌼 alias list \n${chalk.blue(Object.keys(alias).join('\n'))}`);

View File

@ -145,11 +145,11 @@ const initialValue = {
status: [
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
},
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
},
],
};

View File

@ -42,8 +42,7 @@
"resolutions": {
"@types/react": "^18.0.38",
"@types/react-dom": "^18.0.11",
"@types/responselike": "^1.0.0",
"typescript": "~4.8.4"
"@types/responselike": "^1.0.0"
},
"devDependencies": {
"@ant-design/antd-theme-variable": "^1.0.0",
@ -153,7 +152,7 @@
"stylelint": "^13.13.1",
"timezone-mock": "^1.3.6",
"ts-node": "^10.9.1",
"typescript": "~4.8.4",
"typescript": "^5.2.2",
"umi": "^4.0.86",
"umi-request": "^1.4.0",
"use-merge-value": "^1.2.0",

View File

@ -18,8 +18,8 @@ const Card = React.forwardRef((props: CardProps, ref: any) => {
const {
className,
style,
bodyStyle = {},
headStyle = {},
bodyStyle,
headStyle,
title,
subTitle,
extra,
@ -212,7 +212,7 @@ const Card = React.forwardRef((props: CardProps, ref: any) => {
<Loading
prefix={prefixCls}
style={
bodyStyle.padding === 0 || bodyStyle.padding === '0px'
bodyStyle?.padding === 0 || bodyStyle?.padding === '0px'
? { padding: 24 }
: undefined
}

View File

@ -154,7 +154,7 @@ const CheckCard: React.FC<CheckCardProps> & {
props?.onClick?.(e);
const newChecked = !stateChecked;
checkCardGroup?.toggleOption?.({ value: props.value });
setStateChecked?.(newChecked, e);
setStateChecked?.(newChecked);
};
// small => sm large => lg

View File

@ -1,9 +1,9 @@
import { QuestionCircleOutlined } from '@ant-design/icons';
import type { BadgeProps, StatisticProps as AntdStatisticProps } from 'antd';
import type { StatisticProps as AntdStatisticProps, BadgeProps } from 'antd';
import {
Statistic as AntdStatistic,
Badge,
ConfigProvider,
Statistic as AntdStatistic,
Tooltip,
} from 'antd';
import classNames from 'classnames';
@ -43,7 +43,7 @@ const Statistic: React.FC<StatisticProps> = (props) => {
const {
className,
layout = 'inline',
style = {},
style,
description,
children,
title,

View File

@ -102,7 +102,7 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},

View File

@ -24,11 +24,11 @@ const tableListDataSource: TableListItem = {
status: [
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
},
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
},
],
};

View File

@ -10,12 +10,12 @@ import type {
UseEditableMapUtilType,
} from '@ant-design/pro-utils';
import {
compareVersions,
ErrorBoundary,
genCopyable,
getFieldPropsOrFormItemProps,
InlineErrorFormItem,
LabelIconTip,
compareVersions,
genCopyable,
getFieldPropsOrFormItemProps,
stringify,
useEditableMap,
} from '@ant-design/pro-utils';
@ -98,7 +98,7 @@ export type ProDescriptionsProps<
/** 网络请求报错 */
onRequestError?: (e: Error) => void;
/** 获取数据的方法 */
request?: (params: Record<string, any>) => Promise<RequestData>;
request?: (params: Record<string, any> | undefined) => Promise<RequestData>;
columns?: ProDescriptionsItemProps<RecordType, ValueType>[];
@ -481,7 +481,7 @@ const ProDescriptions = <
const {
request,
columns,
params = {},
params,
dataSource,
onDataSourceChange,
formProps,
@ -497,7 +497,7 @@ const ProDescriptions = <
const action = useFetchData<RequestData>(
async () => {
const data = request ? await request(params) : { data: {} };
const data = request ? await request(params || {}) : { data: {} };
return data;
},
{

View File

@ -47,7 +47,7 @@ const FieldDigit: ProFieldFC<FieldDigitProps> = (
[fieldProps],
);
if (type === 'read') {
let fractionDigits = {} as any;
let fractionDigits = {} as Record<string, any> as any;
if (fieldProps?.precision) {
fractionDigits = {
minimumFractionDigits: Number(fieldProps.precision),

View File

@ -159,7 +159,8 @@ const getTextByLocale = (
try {
// Formatting the number, when readonly moneySymbol = false, unused currency.
const finalMoneyText = new Intl.NumberFormat(moneySymbol || 'zh-Hans-CN', {
...(intlMap[moneySymbol || 'zh-Hans-CN'] || intlMap['zh-Hans-CN']),
...(intlMap[(moneySymbol as 'zh-Hans-CN') || 'zh-Hans-CN'] ||
intlMap['zh-Hans-CN']),
maximumFractionDigits: precision,
...config,
})
@ -278,8 +279,8 @@ const FieldMoney: ProFieldFC<FieldMoneyProps> = (
const precision = fieldProps?.precision ?? DefaultPrecisionCont;
let intl = useIntl();
// 当手动传入locale时,应该以传入的locale为准,未传入时则根据全局的locale进行国际化
if (locale && allIntlMap[locale]) {
intl = allIntlMap[locale];
if (locale && allIntlMap[locale as 'zh-CN']) {
intl = allIntlMap[locale as 'zh-CN'];
}
const placeholderValue =
placeholder || intl.getMessage('tableForm.inputPlaceholder', '请输入');

View File

@ -98,7 +98,7 @@ const LightSelect: React.ForwardRefRenderFunction<
});
const valueMap: Record<string, string> = useMemo(() => {
const values = {};
const values = {} as Record<string, any>;
options?.forEach((item) => {
const optionLabel = item[optionLabelProp] || item[labelPropsName];
const optionValue = item[valuePropsName];

View File

@ -152,10 +152,12 @@ const SearchSelect = <T,>(props: SearchSelectProps<T[]>, ref: any) => {
});
const getMergeValue: SelectProps<any>['onChange'] = (value, option) => {
if (Array.isArray(value) && value.length > 0) {
if (Array.isArray(value) && Array.isArray(option) && value.length > 0) {
// 多选情况且用户有选择
return value.map((item, index) => {
const optionItem = option?.[index] as DefaultOptionType;
const optionItem = (option as DefaultOptionType[])?.[
index
] as DefaultOptionType;
const dataItem = optionItem?.['data-item'] || {};
return {
...dataItem,
@ -276,7 +278,7 @@ const SearchSelect = <T,>(props: SearchSelectProps<T[]>, ref: any) => {
return;
}
if (mode !== 'multiple') {
if (mode !== 'multiple' && !Array.isArray(optionList)) {
// 单选情况且用户选择了选项
const dataItem = optionList && optionList['data-item'];
// 如果value值为空则是清空时产生的回调,直接传值就可以了

View File

@ -413,7 +413,7 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},

View File

@ -471,7 +471,7 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},

View File

@ -571,23 +571,23 @@ const defaultRenderText = (
return <FieldText text={dataValue as string} {...props} />;
};
export { defaultRenderText };
export type { ProFieldValueType, FieldMoneyProps };
export {
FieldPercent,
FieldIndexColumn,
FieldProgress,
FieldMoney,
FieldDatePicker,
FieldRangePicker,
defaultRenderText,
FieldCode,
FieldTimePicker,
FieldText,
FieldStatus,
FieldDatePicker,
FieldIndexColumn,
FieldMoney,
FieldPercent,
FieldProgress,
FieldRangePicker,
FieldSelect,
FieldStatus,
FieldText,
FieldTimePicker,
proFieldParsingText,
proFieldParsingValueEnumToArray,
};
export type { FieldMoneyProps, ProFieldValueType };
/** ProField 的类型 */
export type ProFieldPropsType = {

View File

@ -8,10 +8,10 @@ import type {
SearchTransformKeyFn,
} from '@ant-design/pro-utils';
import {
ProFormContext,
conversionMomentValue,
isDeepEqualReact,
nanoid,
ProFormContext,
runFunction,
transformKeySubmitValue,
useFetchData,
@ -39,10 +39,10 @@ import React, {
useRef,
useState,
} from 'react';
import FieldContext from '../FieldContext';
import type { SubmitterProps } from '../components';
import { Submitter } from '../components';
import { FormListContext } from '../components/List';
import FieldContext from '../FieldContext';
import { GridContext, useGridHelpers } from '../helpers';
import type {
FieldProps,
@ -253,7 +253,7 @@ function BaseFormComponents<T = Record<string, any>, U = Record<string, any>>(
form,
loading,
formComponentType,
extraUrlParams = {},
extraUrlParams = {} as Record<string, any>,
syncToUrl,
onUrlSearchChange,
onReset,
@ -394,7 +394,7 @@ function BaseFormComponents<T = Record<string, any>, U = Record<string, any>>(
}, extraUrlParams);
/** 在同步到 url 上时对参数进行转化 */
onUrlSearchChange(genParams(syncToUrl, params, 'set'));
onUrlSearchChange(genParams(syncToUrl, params || {}, 'set'));
}
}}
submitButtonProps={{
@ -494,7 +494,7 @@ function BaseForm<T = Record<string, any>, U = Record<string, any>>(
props: BaseFormProps<T, U>,
) {
const {
extraUrlParams = {},
extraUrlParams = {} as Record<string, any>,
syncToUrl,
isKeyPressSubmit,
syncToUrlAsImportant = false,
@ -819,5 +819,5 @@ function BaseForm<T = Record<string, any>, U = Record<string, any>>(
);
}
export type { FormProps, ProFormInstance, FormItemProps, FormInstance };
export { BaseForm };
export type { FormInstance, FormItemProps, FormProps, ProFormInstance };

View File

@ -70,7 +70,7 @@ const LightWrapper: React.ForwardRefRenderFunction<any, LightWrapperProps> = (
const prefixCls = getPrefixCls('pro-field-light-wrapper');
const { wrapSSR, hashId } = useStyle(prefixCls);
const [tempValue, setTempValue] = useState<string | undefined>(
props[valuePropName!],
(props as any)[valuePropName!],
);
const [open, setOpen] = useMountMergeState<boolean>(false);
@ -79,7 +79,7 @@ const LightWrapper: React.ForwardRefRenderFunction<any, LightWrapperProps> = (
propsOnChange?.(...restParams);
};
const labelValue = props[valuePropName!];
const labelValue = (props as any)[valuePropName!];
/** DataRange的转化,dayjs 的 toString 有点不好用 */
const labelValueText = useMemo(() => {
@ -91,7 +91,7 @@ const LightWrapper: React.ForwardRefRenderFunction<any, LightWrapperProps> = (
) {
return dateArrayFormatter(
labelValue,
dateFormatterMap[valueType] || 'YYYY-MM-DD',
(dateFormatterMap as any)[valueType] || 'YYYY-MM-DD',
);
}
if (Array.isArray(labelValue))

View File

@ -10,8 +10,8 @@ import classnames from 'classnames';
import { FieldContext as RcFieldContext } from 'rc-field-form';
import { noteOnce } from 'rc-util/lib/warning';
import React, { useContext, useMemo, useState } from 'react';
import { ProFormDependency, ProFormItem } from '../components';
import FieldContext from '../FieldContext';
import { ProFormDependency, ProFormItem } from '../components';
import { useGridHelpers } from '../helpers';
import type {
ExtendsProps,
@ -214,7 +214,7 @@ function createField<P extends ProFormFieldItemProps = any>(
const style = useDeepCompareMemo(() => {
const newStyle = {
width:
width && !WIDTH_SIZE_ENUM[width]
width && !WIDTH_SIZE_ENUM[width as 'xs']
? width
: contextValue.grid
? '100%'
@ -229,7 +229,7 @@ function createField<P extends ProFormFieldItemProps = any>(
}, [stringify(fieldProps?.style), contextValue.grid, isIgnoreWidth, width]);
const className = useDeepCompareMemo(() => {
const isSizeEnum = width && WIDTH_SIZE_ENUM[width];
const isSizeEnum = width && WIDTH_SIZE_ENUM[width as 'xs'];
return (
classnames(fieldProps?.className, {
'pro-field': isSizeEnum,

View File

@ -78,7 +78,7 @@ const ProFormDependency = <T,>({
}}
>
{(form) => {
let values: Record<string, any> = {};
let values: Record<string, any> = {} as Record<string, any>;
for (let i = 0; i < nameList.length; i++) {
const itemName = flattenNames[i],
itemOriginName = originDependencies[i];
@ -88,12 +88,12 @@ const ProFormDependency = <T,>({
// transform 会生成多余的value,这里需要注入一下
values = merge({}, values, value);
if (get(value, itemName)) {
values = set(values, finalName, get(value, itemName), false);
values = set(values, finalName, get(value, itemName));
}
} else {
value = form.getFieldValue?.(itemName);
if (typeof value !== 'undefined') {
values = set(values, finalName, value, false);
values = set(values, finalName, value);
}
}
}

View File

@ -30,6 +30,7 @@ const FieldSetType = {
export function defaultGetValueFromEvent(valuePropName: string, ...args: any) {
const event = args[0];
if (event && event.target && valuePropName in event.target) {
// @ts-ignore
return (event.target as HTMLInputElement)[valuePropName];
}
return event;

View File

@ -281,7 +281,7 @@ const ProFormItem: React.FC<ProFormItemProps> = (props) => {
transform,
dataFormat,
ignoreFormItem,
lightProps = {},
lightProps,
children: unusedChildren,
...rest
} = props;
@ -332,11 +332,11 @@ const ProFormItem: React.FC<ProFormItemProps> = (props) => {
isDropdownValueType(valueType || props.children.props.valueType);
const noLightFormItem = useMemo(() => {
if (!lightProps.light || lightProps.customLightMode || isDropdown) {
if (!lightProps?.light || lightProps?.customLightMode || isDropdown) {
return true;
}
return false;
}, [lightProps.customLightMode, isDropdown, lightProps.light]);
}, [lightProps?.customLightMode, isDropdown, lightProps?.light]);
// formItem 支持function,如果是function 我就直接不管了
if (typeof props.children === 'function') {

View File

@ -100,15 +100,17 @@ const Demo = () => {
setJson(JSON.stringify(values));
if (values?.copyIconProps?.Icon) {
values.copyIconProps.Icon = IconMap[values?.copyIconProps?.Icon];
values.copyIconProps.Icon =
IconMap[values?.copyIconProps?.Icon as 'PlusOutlined'];
}
if (values?.deleteIconProps?.Icon) {
values.deleteIconProps.Icon =
IconMap[values?.deleteIconProps?.Icon];
IconMap[values?.deleteIconProps?.Icon as 'PlusOutlined'];
}
if (values?.creatorButtonProps?.icon) {
const Icon = IconMap[values?.creatorButtonProps?.icon];
const Icon =
IconMap[values?.creatorButtonProps?.icon as 'PlusOutlined'];
values.creatorButtonProps.icon = <Icon />;
}
setStateValue(values);
@ -144,7 +146,7 @@ const Demo = () => {
label="图标"
request={async () => {
return Object.keys(IconMap).map((value) => {
const Icon = IconMap[value];
const Icon = IconMap[value as 'PlusOutlined'];
return {
label: <Icon />,
value,
@ -221,7 +223,7 @@ const Demo = () => {
label="图标"
request={async () => {
return Object.keys(IconMap).map((value) => {
const Icon = IconMap[value];
const Icon = IconMap[value as 'PlusOutlined'];
return {
label: <Icon />,
value,
@ -264,7 +266,7 @@ const Demo = () => {
label="图标"
request={async () => {
return Object.keys(IconMap).map((value) => {
const Icon = IconMap[value];
const Icon = IconMap[value as 'PlusOutlined'];
return {
label: <Icon />,
value,

View File

@ -156,11 +156,13 @@ export default () => {
status: [
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label:
valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '1'],
},
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label:
valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '1'],
},
],
}}

View File

@ -43,6 +43,7 @@ const FormLayoutType = {
StepsForm: StepsForm,
ModalForm,
Embed,
Form: ProForm,
};
/**
@ -64,7 +65,7 @@ function BetaSchemaForm<T, ValueType = 'text'>(
...restProps
} = props;
const FormRenderComponents = (FormLayoutType[layoutType] ||
const FormRenderComponents = (FormLayoutType[layoutType as 'Form'] ||
ProForm) as React.FC<ProFormProps<T>>;
const [form] = Form.useForm();

View File

@ -55,7 +55,7 @@ const Submitter: React.FC<SubmitterProps> = (props) => {
onReset,
searchConfig = {},
submitButtonProps,
resetButtonProps = {},
resetButtonProps,
} = props;
const { token } = proTheme.useToken();
@ -80,7 +80,7 @@ const Submitter: React.FC<SubmitterProps> = (props) => {
if (resetButtonProps !== false) {
dom.push(
<Button
{...omit(resetButtonProps, ['preventDefault'])}
{...omit(resetButtonProps, ['preventDefault'] as any)}
key="rest"
onClick={(e) => {
if (!resetButtonProps?.preventDefault) reset();

View File

@ -19,7 +19,7 @@ import {
QueryFilter,
StepsForm,
} from '@ant-design/pro-components';
import { Button, message, Space } from 'antd';
import { Button, Space, message } from 'antd';
import { useState } from 'react';
const iconStyles = {
@ -39,7 +39,6 @@ const waitTime = (time: number = 100) => {
};
export default () => {
const [type, setType] = useState('ProForm');
const Components = {
ProForm,
ModalForm,
@ -49,6 +48,7 @@ export default () => {
StepsForm,
LoginForm,
};
const [type, setType] = useState<keyof typeof Components>('ProForm');
if (type === 'StepsForm') {
return (
@ -158,12 +158,11 @@ export default () => {
);
}
const FormComponents = Components[type];
const FormComponents = Components[type as 'LoginForm'];
if (type === 'LoginForm') {
return (
<>
{' '}
<ProFormRadio.Group
style={{
margin: 16,
@ -255,6 +254,7 @@ export default () => {
}}
>
<FormComponents
// @ts-ignore
labelWidth="auto"
trigger={
<Button type="primary">

View File

@ -23,7 +23,7 @@ export const gridHelpers: (
config: ProFormGridConfig & CommonProps,
) => GridHelpers = ({ grid, rowProps, colProps }) => ({
grid: !!grid,
RowWrapper({ children, Wrapper, ...props } = {}) {
RowWrapper({ children, Wrapper, ...props } = {} as Record<string, any>) {
if (!grid) {
return Wrapper ? <Wrapper>{children}</Wrapper> : (children as any);
}
@ -34,7 +34,7 @@ export const gridHelpers: (
</Row>
);
},
ColWrapper({ children, Wrapper, ...rest } = {}) {
ColWrapper({ children, Wrapper, ...rest } = {} as Record<string, any>) {
const props = useMemo(() => {
const originProps = { ...colProps, ...rest };

View File

@ -105,7 +105,7 @@ function DrawerForm<T = Record<string, any>, U = Record<string, any>>({
}: DrawerFormProps<T, U>) {
noteOnce(
// eslint-disable-next-line @typescript-eslint/dot-notation
!rest['footer'] || !drawerProps?.footer,
!(rest as any)['footer'] || !drawerProps?.footer,
'DrawerForm 是一个 ProForm 的特殊布局,如果想自定义按钮,请使用 submit.render 自定义。',
);
const resizeInfo: CustomizeResizeType = React.useMemo(() => {

View File

@ -197,7 +197,7 @@ const LightFilterContainer: React.FC<{
setOpen(false);
},
onClear: () => {
const clearValues = {};
const clearValues = {} as Record<string, any>;
collapseItems.forEach((child: any) => {
const { name } = child.props;
clearValues[name] = undefined;

View File

@ -77,7 +77,7 @@ export function LoginFormPage<T = Record<string, any>>(
logo,
message,
style,
activityConfig = {},
activityConfig,
backgroundImageUrl,
backgroundVideoUrl,
title,

View File

@ -85,7 +85,7 @@ function ModalForm<T = Record<string, any>, U = Record<string, any>>({
}: ModalFormProps<T, U>) {
noteOnce(
// eslint-disable-next-line @typescript-eslint/dot-notation
!rest['footer'] || !modalProps?.footer,
!(rest as any)['footer'] || !modalProps?.footer,
'ModalForm 是一个 ProForm 的特殊布局,如果想自定义按钮,请使用 submit.render 自定义。',
);

View File

@ -59,20 +59,27 @@ const getSpanConfig = (
};
}
const spanConfig = span
const spanConfig: (string | number)[][] = span
? ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'].map((key) => [
CONFIG_SPAN_BREAKPOINTS[key],
24 / span[key],
CONFIG_SPAN_BREAKPOINTS[key as 'xs'],
24 / (span as any)[key as 'sm'],
'horizontal',
])
: BREAKPOINTS[layout || 'default'];
: BREAKPOINTS[(layout as 'default') || 'default'];
const breakPoint = (spanConfig || BREAKPOINTS.default).find(
(item: [number, number, FormProps['layout']]) => width < item[0] + 16, // 16 = 2 * (ant-row -8px margin)
(item) => width < (item[0] as number) + 16, // 16 = 2 * (ant-row -8px margin)
);
if (!breakPoint) {
return {
span: 8,
layout: 'horizontal',
};
}
return {
span: 24 / breakPoint[1],
layout: breakPoint[2],
span: 24 / (breakPoint[1] as number),
layout: breakPoint?.[2] as 'horizontal',
};
};

View File

@ -1,8 +1,8 @@
import type { GenerateStyle, ProTokenType } from '@ant-design/pro-provider';
import {
isNeedOpenHash,
ProConfigProvider,
ProProvider,
isNeedOpenHash,
} from '@ant-design/pro-provider';
import {
coverToNewToken,
@ -14,8 +14,8 @@ import {
import { getMatchMenu } from '@umijs/route-utils';
import type { BreadcrumbProps } from 'antd';
import { ConfigProvider, Layout } from 'antd';
import type { ItemType } from 'antd/es/breadcrumb/Breadcrumb';
import type { AnyObject } from 'antd/es/_util/type';
import type { ItemType } from 'antd/es/breadcrumb/Breadcrumb';
import classNames from 'classnames';
import Omit from 'omit.js';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
@ -29,6 +29,7 @@ import React, {
useState,
} from 'react';
import useSWR, { useSWRConfig } from 'swr';
import { WrapContent } from './WrapContent';
import { Logo } from './assert/Logo';
import { DefaultFooter as Footer } from './components/Footer';
import type { HeaderViewProps } from './components/Header';
@ -57,7 +58,6 @@ import { getBreadcrumbProps } from './utils/getBreadcrumbProps';
import { getMenuData } from './utils/getMenuData';
import { useCurrentMenuLayoutProps } from './utils/useCurrentMenuLayoutProps';
import { clearMenuItem } from './utils/utils';
import { WrapContent } from './WrapContent';
let layoutIndex = 0;
@ -532,7 +532,7 @@ const BaseProLayout: React.FC<ProLayoutProps> = (props) => {
[formatMessage, menu, menuDataRender, data, route?.children, route?.routes],
);
const { breadcrumb = {}, breadcrumbMap, menuData = [] } = menuInfoData || {};
const { breadcrumb, breadcrumbMap, menuData = [] } = menuInfoData || {};
if (actionRef && menu?.request) {
actionRef.current = {

View File

@ -309,7 +309,7 @@ const memoRenderPageHeader = (
'footer',
'avatar',
'backIcon',
].every((item) => !pageHeaderProps[item]) &&
].every((item) => !pageHeaderProps[item as 'backIcon']) &&
noHasBreadCrumb &&
!content &&
!extraContent
@ -503,4 +503,4 @@ const ProPageHeader = (
});
};
export { ProPageHeader, PageContainer, ProBreadcrumb };
export { PageContainer, ProBreadcrumb, ProPageHeader };

View File

@ -22,7 +22,7 @@ const LayoutSetting: React.FC<{
changeSetting: (key: string, value: any, hideLoading?: boolean) => void;
hashId: string;
prefixCls: string;
}> = ({ settings = {}, prefixCls, changeSetting, hashId }) => {
}> = ({ settings, prefixCls, changeSetting, hashId }) => {
const formatMessage = getFormatMessage();
const { contentWidth, splitMenus, fixedHeader, layout, fixSiderbar } =
settings || defaultSettings;

View File

@ -1,15 +1,15 @@
import { List, Switch } from 'antd';
import React from 'react';
import type { ProSettings } from '../../defaultSettings';
import { getFormatMessage } from './index';
import { renderLayoutSettingItem } from './LayoutChange';
import { getFormatMessage } from './index';
const RegionalSetting: React.FC<{
settings: Partial<ProSettings>;
changeSetting: (key: string, value: any, hideLoading?: boolean) => void;
hashId: string;
prefixCls: string;
}> = ({ settings = {}, prefixCls, changeSetting, hashId }) => {
}> = ({ settings, prefixCls, changeSetting, hashId }) => {
const formatMessage = getFormatMessage();
const regionalSetting = ['header', 'footer', 'menu', 'menuHeader'];
return (
@ -25,8 +25,8 @@ const RegionalSetting: React.FC<{
size="small"
className={`regional-${key} ${hashId}`.trim()}
checked={
settings[`${key}Render`] ||
settings[`${key}Render`] === undefined
settings[`${key}Render` as 'headerRender'] ||
settings[`${key}Render` as 'headerRender'] === undefined
}
onChange={(checked) =>
changeSetting(

View File

@ -13,13 +13,13 @@ import {
import { useUrlSearchParams } from '@umijs/use-params';
import {
Alert,
Button,
ConfigProvider as AntConfigProvider,
Button,
Divider,
Drawer,
List,
message,
Switch,
message,
version,
} from 'antd';
import omit from 'omit.js';
@ -27,15 +27,15 @@ import useMergedState from 'rc-util/lib/hooks/useMergedState';
import React, { useEffect, useRef, useState } from 'react';
import type { ProSettings } from '../../defaultSettings';
import { defaultSettings } from '../../defaultSettings';
import { getLanguage, gLocaleObject } from '../../locales';
import { gLocaleObject, getLanguage } from '../../locales';
import { genStringToTheme } from '../../utils/utils';
import { BlockCheckbox } from './BlockCheckbox';
import { GroupIcon } from './icon/group';
import { SubIcon } from './icon/sub';
import { LayoutSetting, renderLayoutSettingItem } from './LayoutChange';
import { RegionalSetting } from './RegionalChange';
import { useStyle } from './style/index';
import { ThemeColor } from './ThemeColor';
import { GroupIcon } from './icon/group';
import { SubIcon } from './icon/sub';
import { useStyle } from './style/index';
type BodyProps = {
title: string;
@ -86,18 +86,25 @@ export type SettingDrawerState = {
language?: string;
} & MergerSettingsType<ProSettings>;
type StateKey = keyof ProSettings;
const getDifferentSetting = (
state: Partial<ProSettings>,
): Record<string, any> => {
const stateObj: Partial<ProSettings> = {};
Object.keys(state).forEach((key) => {
if (state[key] !== defaultSettings[key] && key !== 'collapse') {
stateObj[key] = state[key];
const stateObj = {} as typeof state;
(Object.keys(state) as StateKey[]).forEach((key) => {
if (
state[key] !== defaultSettings[key] &&
//@ts-ignore
key !== 'collapse'
) {
stateObj[key as 'navTheme'] = state[key as 'navTheme'];
} else {
stateObj[key] = undefined;
}
if (key.includes('Render'))
stateObj[key] = state[key] === false ? false : undefined;
stateObj[key as 'headerRender'] =
state[key] === false ? false : undefined;
});
stateObj.menu = undefined;
return stateObj;
@ -131,9 +138,12 @@ const initState = (
) => {
if (!isBrowser()) return;
const replaceSetting = {};
const replaceSetting = {} as Record<string, any>;
Object.keys(urlParams).forEach((key) => {
if (defaultSettings[key] || defaultSettings[key] === undefined) {
if (
defaultSettings[key as 'navTheme'] ||
defaultSettings[key as 'navTheme'] === undefined
) {
if (key === 'colorPrimary') {
replaceSetting[key] = genStringToTheme(urlParams[key]);
return;
@ -276,7 +286,7 @@ export const SettingDrawer: React.FC<SettingDrawerProps> = (props) => {
* @param value
*/
const changeSetting = (key: string, value: string | boolean) => {
const nextState = {} as any;
const nextState = {} as Record<string, any> as any;
nextState[key] = value;
if (key === 'layout') {

View File

@ -514,7 +514,7 @@ const getOpenKeysProps = (
): {
openKeys?: undefined | string[];
} => {
let openKeysProps = {};
let openKeysProps = {} as Record<string, any>;
if (openKeys && !collapsed && ['side', 'mix'].includes(layout || 'mix')) {
openKeysProps = {

View File

@ -33,7 +33,7 @@ export const renderLogoAndTitle = (
renderKey: HeaderRenderKey = 'menuHeaderRender',
): React.ReactNode => {
const { logo, title, layout } = props;
const renderFunction = props[renderKey || ''];
const renderFunction = props[renderKey as 'menuHeaderRender'];
if (renderFunction === false) {
return null;
}

View File

@ -28,7 +28,7 @@ for (let i = 0; i < 10; i += 1) {
name: 'AppName',
containers: Math.floor(Math.random() * 20),
creator: creators[Math.floor(Math.random() * creators.length)],
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 100000),
memo:
i % 2 === 1

View File

@ -38,7 +38,7 @@ const defaultMenus = [
const loopMenuItem = (menus: any[]): MenuDataItem[] =>
menus.map(({ icon, routes, ...item }) => ({
...item,
icon: icon && IconMap[icon as string],
icon: icon && IconMap[icon as 'smile'],
children: routes && loopMenuItem(routes),
}));

View File

@ -29,5 +29,5 @@ export const getLanguage = (): string => {
};
export const gLocaleObject = (): Record<string, string> => {
const gLocale = getLanguage();
return locales[gLocale] || locales['zh-CN'];
return locales[gLocale as 'zh-CN'] || locales['zh-CN'];
};

View File

@ -31,7 +31,9 @@ const themeConfig = {
* @param val
*/
export function genStringToTheme(val?: string): string {
return val && themeConfig[val] ? themeConfig[val] : val;
return val && themeConfig[val as 'techBlue']
? themeConfig[val as 'techBlue']
: val || '';
}
export function clearMenuItem(menusData: MenuDataItem[]): MenuDataItem[] {
return menusData

View File

@ -15,10 +15,10 @@ import type { GetRowKey, TableRowSelection } from 'antd/lib/table/interface';
import classNames from 'classnames';
import get from 'rc-util/lib/utils/get';
import React, { useContext } from 'react';
import { PRO_LIST_KEYS_MAP } from './constants';
import type { GetComponentProps } from './index';
import type { ItemProps } from './Item';
import ProListItem from './Item';
import { PRO_LIST_KEYS_MAP } from './constants';
import type { GetComponentProps } from './index';
import { compareVersions } from '@ant-design/pro-utils';
import type { AnyObject } from 'antd/es/_util/type';
@ -253,7 +253,7 @@ function ListView<RecordType extends AnyObject>(
const data = column.render
? column.render(rawData, item, index)
: rawData;
if (data !== '-') listItemProps[column.listKey] = data;
if (data !== '-') (listItemProps as any)[column.listKey] = data;
});
let checkboxDom: React.ReactNode;
if (selectItemDom && selectItemDom.render) {

View File

@ -32,7 +32,7 @@ export default () => (
}}
rowKey="name"
headerTitle="基础列表"
request={async (params = {}) =>
request={async (params = {} as Record<string, any>) =>
request<{
data: GithubIssueItem[];
}>('https://proapi.azurewebsites.net/github/issues', {

View File

@ -30,7 +30,7 @@ export default () => (
search={{}}
rowKey="name"
headerTitle="基础列表"
request={async (params = {}) =>
request={async (params = {} as Record<string, any>) =>
request<{
data: GithubIssueItem[];
}>('https://proapi.azurewebsites.net/github/issues', {

View File

@ -248,8 +248,8 @@ const ConfigProviderContainer: React.FC<{
// antd 的 key 存在的时候以 antd 的为主
const intl =
localeName && proProvide.intl?.locale === 'default'
? intlMap[key!]
: proProvide.intl || intlMap[key!];
? intlMap[key! as 'zh-CN']
: proProvide.intl || intlMap[key! as 'zh-CN'];
return {
...proProvide,
@ -435,7 +435,9 @@ export function useIntl(): IntlType {
}
if (locale?.locale) {
return intlMap[findIntlKeyByAntdLocaleKey(locale.locale)] || zhCNIntl;
return (
intlMap[findIntlKeyByAntdLocaleKey(locale.locale) as 'zh-CN'] || zhCNIntl
);
}
return zhCNIntl;

View File

@ -105,7 +105,8 @@ export function useStyle(
componentName: string,
styleFn: (token: ProAliasToken) => CSSInterpolation,
) {
let { token = {} as ProAliasToken } = useContext(ProProvider);
let { token = {} as Record<string, any> as ProAliasToken } =
useContext(ProProvider);
const { hashId = '', theme: provideTheme } = useContext(ProProvider);
const { token: antdToken } = useToken();
const { getPrefixCls } = useContext(AntdConfigProvider.ConfigContext);

View File

@ -1,5 +1,5 @@
export const merge = <T extends Record<string, any>>(...rest: any[]): T => {
const obj = {};
const obj = {} as Record<string, any>;
const il = rest.length;
let key;
let i = 0;

View File

@ -117,9 +117,10 @@ const DescriptionsItemSkeleton: React.FC<{
const col = Grid.useBreakpoint() || defaultCol;
const colSize =
Object.keys(col).filter((key) => col[key] === true)[0] || 'md';
Object.keys(col).filter((key) => col[key as 'lg'] === true)[0] || 'md';
const arraySize = size === undefined ? MediaQueryKeyEnum[colSize] || 3 : size;
const arraySize =
size === undefined ? MediaQueryKeyEnum[colSize as 'md'] || 3 : size;
return (
<div
style={{
@ -191,9 +192,9 @@ export const TableItemSkeleton = ({
const col = Grid.useBreakpoint() || defaultCol;
const colSize =
Object.keys(col).filter((key) => col[key] === true)[0] || 'md';
Object.keys(col).filter((key) => col[key as 'md'] === true)[0] || 'md';
const arraySize = MediaQueryKeyEnum[colSize] || 3;
const arraySize = MediaQueryKeyEnum[colSize as 'md'] || 3;
return (
<>
<div

View File

@ -39,9 +39,10 @@ const StatisticSkeleton: React.FC<{
const col = Grid.useBreakpoint() || defaultCol;
const colSize =
Object.keys(col).filter((key) => col[key] === true)[0] || 'md';
Object.keys(col).filter((key) => col[key as 'md'] === true)[0] || 'md';
const arraySize = size === undefined ? MediaQueryKeyEnum[colSize] || 6 : size;
const arraySize =
size === undefined ? MediaQueryKeyEnum[colSize as 'md'] || 6 : size;
const firstWidth = (index: number) => {
if (index === 0) {
return 0;

View File

@ -37,7 +37,7 @@ export type UseContainerProps<T = any> = {
columnsState?: ProTableProps<any, any, any>['columnsState'];
};
function useContainer(props: UseContainerProps = {}) {
function useContainer(props: UseContainerProps = {} as Record<string, any>) {
const actionRef = useRef<ActionType>();
const rootDomRef = useRef<HTMLDivElement>(null);
/** 父 form item 的 name */
@ -63,7 +63,7 @@ function useContainer(props: UseContainerProps = {}) {
const defaultColumnKeyMap = useMemo(() => {
if (props?.columnsState?.defaultValue)
return props.columnsState.defaultValue;
const columnKeyMap = {};
const columnKeyMap = {} as Record<string, any>;
props.columns?.forEach(({ key, dataIndex, fixed, disable }, index) => {
const columnKey = genColumnKey(key ?? (dataIndex as React.Key), index);
if (columnKey) {
@ -239,4 +239,4 @@ const Container: React.FC<{
);
};
export { TableContext, Container };
export { Container, TableContext };

View File

@ -8,8 +8,8 @@ import ProForm, { GridContext } from '@ant-design/pro-form';
import type { ParamsType } from '@ant-design/pro-provider';
import { ProConfigProvider, proTheme, useIntl } from '@ant-design/pro-provider';
import {
editableRowByKey,
ErrorBoundary,
editableRowByKey,
omitUndefined,
recordKeyToString,
stringify,
@ -37,10 +37,10 @@ import React, {
useRef,
} from 'react';
import type { ActionType } from '.';
import { Container, TableContext } from './Store/Provide';
import Alert from './components/Alert';
import FormRender from './components/Form';
import Toolbar from './components/ToolBar';
import { Container, TableContext } from './Store/Provide';
import { useStyle } from './style';
import type {
OptionSearchProps,
@ -412,7 +412,7 @@ function TableRender<T extends Record<string, any>, U, ValueType>(
);
}
const emptyObj = {};
const emptyObj = {} as Record<string, any>;
const ProTable = <
T extends Record<string, any>,

View File

@ -398,7 +398,7 @@ function ColumnSetting<T>(props: ColumnSettingProps<T>) {
* @param show
*/
const setAllSelectAction = useRefFunction((show: boolean = true) => {
const columnKeyMap = {};
const columnKeyMap = {} as Record<string, any>;
const loopColumns = (columns: any) => {
columns.forEach(({ key, fixed, index, children, disable }: any) => {
const columnKey = genColumnKey(key, index);

View File

@ -1,5 +1,5 @@
import { proTheme, useIntl } from '@ant-design/pro-provider';
import { compareVersions, LabelIconTip } from '@ant-design/pro-utils';
import { LabelIconTip, compareVersions } from '@ant-design/pro-utils';
import {
ConfigProvider,
Input,
@ -112,8 +112,9 @@ const ListToolBarTabBar: React.FC<{
filtersNode: React.ReactNode;
multipleLine: boolean;
tabs: ListToolBarProps['tabs'];
}> = ({ prefixCls, tabs = {}, multipleLine, filtersNode }) => {
}> = ({ prefixCls, tabs, multipleLine, filtersNode }) => {
if (!multipleLine) return null;
if (!tabs) return null;
return (
<div className={`${prefixCls}-extra-line`}>
{tabs.items && tabs.items.length ? (
@ -156,7 +157,7 @@ const ListToolBar: React.FC<ListToolBarProps> = ({
filter,
actions = [],
settings = [],
tabs = {},
tabs,
menu,
}) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);

View File

@ -109,15 +109,17 @@ function renderDefaultOption<T>(
return Object.keys(options)
.filter((item) => item)
.map((key) => {
const value = options[key];
const value = options[key as 'fullScreen'];
if (!value) {
return null;
}
let onClick: OptionsFunctionType =
let onClick =
value === true
? defaultOptions[key]
: (event) => value?.(event, actions.current);
? defaultOptions[key as keyof OptionConfig]
: (event: any) => {
value?.(event, actions.current);
};
if (typeof onClick !== 'function') {
onClick = () => {};
@ -139,7 +141,9 @@ function renderDefaultOption<T>(
</span>
);
}
const optionItem = getButtonText(defaultOptions, options)[key];
const optionItem = getButtonText(defaultOptions, options)[
key as 'fullScreen'
];
if (optionItem) {
return (
<span key={key} onClick={onClick}>

View File

@ -16,7 +16,7 @@ const ProcessMap = {
running: 'active',
online: 'success',
error: 'exception',
};
} as const;
export type TableListItem = {
key: number;
@ -41,7 +41,7 @@ for (let i = 0; i < 50; i += 1) {
callNumber: Math.floor(Math.random() * 2000),
progress: Math.ceil(Math.random() * 100) + 1,
creator: creators[Math.floor(Math.random() * creators.length)],
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 100000),
memo:
i % 2 === 1
@ -77,7 +77,7 @@ const columns: ProColumns<TableListItem>[] = [
dataIndex: 'progress',
valueType: (item) => ({
type: 'progress',
status: ProcessMap[item.status],
status: ProcessMap[item.status as 'close'],
}),
},
{

View File

@ -23,7 +23,7 @@ for (let i = 0; i < 2; i += 1) {
tableListDataSource.push({
key: i,
name: `TradeCode ${i}`,
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
updatedAt: Date.now() - Math.floor(Math.random() * 1000),
createdAt: Date.now() - Math.floor(Math.random() * 2000),
money: Math.floor(Math.random() * 2000) * i,

View File

@ -117,7 +117,7 @@ export default () => {
showQuickJumper: true,
}}
actionRef={actionRef}
request={async (params = {}) =>
request={async (params = {} as Record<string, any>) =>
request<{
data: GithubIssueItem[];
}>('https://proapi.azurewebsites.net/github/issues', {

View File

@ -9,7 +9,7 @@ import {
ProTable,
TableDropdown,
} from '@ant-design/pro-components';
import { Button, message, Space, Tabs, Tag } from 'antd';
import { Button, Space, Tabs, Tag, message } from 'antd';
import { useState } from 'react';
import request from 'umi-request';
@ -123,7 +123,7 @@ export default () => {
<ProTable<GithubIssueItem>
columns={columns}
type={type as 'table'}
request={async (params = {}) =>
request={async (params = {} as Record<string, any>) =>
request<{
data: GithubIssueItem[];
}>('https://proapi.azurewebsites.net/github/issues', {

View File

@ -28,11 +28,11 @@ for (let i = 0; i < 5; i += 1) {
status: [
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
},
{
value: Math.floor(Math.random() * 10),
label: valueEnum[Math.floor(Math.random() * 10) % 4],
label: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
},
],
});

View File

@ -31,7 +31,7 @@ for (let i = 0; i < 5; i += 1) {
name: 'AppName',
containers: Math.floor(Math.random() * 20),
creator: creators[Math.floor(Math.random() * creators.length)],
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 2000),
money: Math.floor(Math.random() * 2000) * i,
progress: Math.ceil(Math.random() * 100) + 1,

View File

@ -31,7 +31,7 @@ for (let i = 0; i < 5; i += 1) {
name: 'AppName',
containers: Math.floor(Math.random() * 20),
creator: creators[Math.floor(Math.random() * creators.length)],
status: valueEnum[Math.floor(Math.random() * 10) % 2],
status: valueEnum[((Math.floor(Math.random() * 10) % 2) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 2000),
money: Math.floor(Math.random() * 2000) * i,
progress: Math.ceil(Math.random() * 100) + 1,

View File

@ -68,7 +68,7 @@ export default () => {
const actionRef = useRef<ActionType>();
const [intl, setIntl] = useState('zhCNIntl');
return (
<ConfigProvider locale={intlMap[intl]}>
<ConfigProvider locale={intlMap[intl as 'zhCNIntl']}>
<ProTable<GithubIssueItem>
columns={columns}
actionRef={actionRef}
@ -97,7 +97,7 @@ export default () => {
bordered={false}
value={intl}
onChange={(value) => {
dayjs.locale(intlMap[value].locale);
dayjs.locale(intlMap[value as 'zhCNIntl'].locale);
setIntl(value);
}}
options={Object.keys(intlMap).map((value) => ({

View File

@ -32,7 +32,7 @@ for (let i = 0; i < 5; i += 1) {
key: i,
name: 'AppName',
containers: Math.floor(Math.random() * 20),
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 2000),
creator: creators[Math.floor(Math.random() * creators.length)],
});

View File

@ -29,7 +29,7 @@ for (let i = 0; i < 5; i += 1) {
name: 'AppName',
containers: Math.floor(Math.random() * 20),
creator: creators[Math.floor(Math.random() * creators.length)],
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 100000),
memo:
i % 2 === 1

View File

@ -29,7 +29,7 @@ for (let i = 0; i < 5; i += 1) {
name: 'AppName',
containers: Math.floor(Math.random() * 20),
creator: creators[Math.floor(Math.random() * creators.length)],
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 100000),
memo:
i % 2 === 1

View File

@ -27,7 +27,7 @@ for (let i = 0; i < 2; i += 1) {
tableListDataSource.push({
key: i,
name: `TradeCode ${i}`,
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
updatedAt: Date.now() - Math.floor(Math.random() * 1000),
createdAt: Date.now() - Math.floor(Math.random() * 2000),
money: Math.floor(Math.random() * 2000) * i,

View File

@ -110,7 +110,7 @@ export default () => {
<ProTable<GithubIssueItem>
columns={columns}
actionRef={actionRef}
request={async (params = {}) =>
request={async (params = {} as Record<string, any>) =>
request<{
data: GithubIssueItem[];
}>('https://proapi.azurewebsites.net/github/issues', {

View File

@ -153,7 +153,7 @@ export default () => {
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params = {}, sort, filter) => {
request={async (params, sort, filter) => {
console.log(sort, filter);
await waitTime(2000);
return request<{

View File

@ -93,7 +93,7 @@ for (let i = 0; i < 10; i += 1) {
ip: `106.14.98.1${i}4`,
cpu: 10,
mem: 20,
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
disk: 30,
});
}

View File

@ -49,7 +49,7 @@ for (let i = 0; i < 5; i += 1) {
name: 'AppName',
containers: Math.floor(Math.random() * 20),
creator: creators[Math.floor(Math.random() * creators.length)],
status: statusMap[Math.floor(Math.random() * 10) % 5],
status: statusMap[((Math.floor(Math.random() * 10) % 5) + '') as '0'],
createdAt: Date.now() - Math.floor(Math.random() * 100000),
});
}

View File

@ -155,7 +155,7 @@ export default () => {
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params = {}, sort, filter) => {
request={async (params, sort, filter) => {
console.log(sort, filter);
return request<{
data: GithubIssueItem[];

View File

@ -34,7 +34,7 @@ for (let i = 0; i < 2; i += 1) {
image:
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
name: `TradeCode ${i}`,
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
updatedAt:
dayjs('2019-11-16 12:50:26').valueOf() - Math.floor(Math.random() * 1000),
createdAt:

View File

@ -25,7 +25,7 @@ for (let i = 0; i < 2; i += 1) {
tableListDataSource.push({
key: i,
name: `TradeCode ${i}`,
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
updatedAt: Date.now() - Math.floor(Math.random() * 1000),
createdAt: Date.now() - Math.floor(Math.random() * 2000),
createdAtRange: [

View File

@ -25,7 +25,7 @@ for (let i = 0; i < 2; i += 1) {
tableListDataSource.push({
key: i,
name: `TradeCode ${i}`,
status: valueEnum[Math.floor(Math.random() * 10) % 4],
status: valueEnum[((Math.floor(Math.random() * 10) % 4) + '') as '0'],
updatedAt: Date.now() - Math.floor(Math.random() * 1000),
createdAt: Date.now() - Math.floor(Math.random() * 2000),
createdAtRange: [

View File

@ -49,7 +49,7 @@ const tableListDataSource: TableListItem[] = [];
for (let i = 0; i < 2; i += 1) {
tableListDataSource.push({
key: i,
status: valueEnumMap[Math.floor(Math.random() * 10) % 3],
status: valueEnumMap[((Math.floor(Math.random() * 10) % 3) + '') as '0'],
cascader: ['fe', 'js'],
treeSelect: ['fe', 'js'],
});

View File

@ -151,17 +151,19 @@ export function genProColumnToColumn<T>(
rowData !== null &&
Reflect.has(rowData as any, keyName)
) {
uniqueKey = rowData[keyName];
uniqueKey = (rowData as Record<string, any>)[keyName as string];
const parentInfo = subNameRecord.get(uniqueKey) || [];
rowData[childrenColumnName]?.forEach((item: any) => {
const itemUniqueKey = item[keyName];
if (!subNameRecord.has(itemUniqueKey)) {
subNameRecord.set(
itemUniqueKey,
parentInfo.concat([index, childrenColumnName]),
);
}
});
(rowData as Record<string, any>)[childrenColumnName]?.forEach(
(item: any) => {
const itemUniqueKey = item[keyName];
if (!subNameRecord.has(itemUniqueKey)) {
subNameRecord.set(
itemUniqueKey,
parentInfo.concat([index, childrenColumnName]),
);
}
},
);
}
const renderProps = {

View File

@ -192,8 +192,11 @@ function parseDataIndex(
export function parseDefaultColumnConfig<T, Value>(
columns: ProColumns<T, Value>[],
) {
const filter: Record<string, (string | number)[] | null> = {};
const sort: Record<string, SortOrder> = {};
const filter: Record<string, (string | number)[] | null> = {} as Record<
string,
any
>;
const sort: Record<string, SortOrder> = {} as Record<string, any>;
columns.forEach((column) => {
// 转换 dataIndex
const dataIndex = parseDataIndex(column.dataIndex);

View File

@ -34,6 +34,7 @@ export function coverToNewToken(
const newToken = { ...token };
Object.keys(deprecatedTokens).forEach((key) => {
if (newToken[key] !== undefined) {
// @ts-ignore
newToken[deprecatedTokens[key]] = newToken[key];
delete newToken[key];
}

View File

@ -88,7 +88,9 @@ export const convertMoment = (
return value.valueOf();
}
if (dateFormatter === 'string') {
return value.format(dateFormatterMap[valueType] || 'YYYY-MM-DD HH:mm:ss');
return value.format(
dateFormatterMap[valueType as 'date'] || 'YYYY-MM-DD HH:mm:ss',
);
}
if (typeof dateFormatter === 'string' && dateFormatter !== 'string') {
return value.format(dateFormatter);
@ -123,7 +125,7 @@ export const conversionMomentValue = <T extends {} = any>(
omitNil?: boolean,
parentKey?: NamePath,
): T => {
const tmpValue = {} as T;
const tmpValue = {} as Record<string, any> as T;
if (typeof window === 'undefined') return value;
// 如果 value 是 string | null | Blob类型 其中之一,直接返回
// 形如 {key: [File, File]} 的表单字段当进行第二次递归时会导致其直接越过 typeof value !== 'object' 这一判断 https://github.com/ant-design/pro-components/issues/2071
@ -163,7 +165,7 @@ export const conversionMomentValue = <T extends {} = any>(
// 不是 moment
!isMoment(itemValue)
) {
tmpValue[valueKey] = conversionMomentValue(
(tmpValue as any)[valueKey] = conversionMomentValue(
itemValue,
dateFormatter,
valueTypeMap,
@ -174,7 +176,7 @@ export const conversionMomentValue = <T extends {} = any>(
}
// 处理 FormList 的 value
if (Array.isArray(itemValue)) {
tmpValue[valueKey] = itemValue.map((arrayValue, index) => {
(tmpValue as any)[valueKey] = itemValue.map((arrayValue, index) => {
if (dayjs.isDayjs(arrayValue) || isMoment(arrayValue)) {
return convertMoment(
arrayValue,
@ -192,7 +194,7 @@ export const conversionMomentValue = <T extends {} = any>(
});
return;
}
tmpValue[valueKey] = convertMoment(
(tmpValue as any)[valueKey] = convertMoment(
itemValue,
dateFormat || dateFormatter,
valueType,

View File

@ -28,8 +28,8 @@ export function useRefCallback<T>(
return new Proxy(defaultValue, {
set(target, prop, newValue: T) {
if (!Object.is(target[prop], newValue)) {
target[prop] = newValue;
if (!Object.is((target as any)[prop], newValue)) {
(target as any)[prop] = newValue;
callback(ref);
}

View File

@ -48,6 +48,7 @@ export function isDeepEqualReact(
length = a.length;
// @ts-ignore
if (length != b.length) return false;
// @ts-ignore
for (i = length; i-- !== 0; ) if (a[i] !== b[i]) return false;
return true;
}

View File

@ -5,8 +5,8 @@
* @param {any[]} ...rest
* @returns T
*/
const merge = <T>(...rest: any[]): T => {
const obj = {};
const merge = <T = any>(...rest: any[]): T => {
const obj = {} as Record<string, any> as any;
const il = rest.length;
let key;
let i = 0;

View File

@ -2,11 +2,13 @@ type OmitUndefined<T> = {
[P in keyof T]: NonNullable<T[P]>;
};
export const omitUndefined = <T>(obj: T): OmitUndefined<T> => {
const newObj = {} as T;
export const omitUndefined = <T extends Record<string, any>>(
obj: T,
): OmitUndefined<T> => {
const newObj = {} as Record<string, any> as T;
Object.keys(obj || {}).forEach((key) => {
if (obj[key] !== undefined) {
newObj[key] = obj[key];
(newObj as any)[key] = obj[key];
}
});
if (Object.keys(newObj as Record<string, any>).length < 1) {

View File

@ -1,5 +1,7 @@
export const omitUndefinedAndEmptyArr = <T>(obj: T): T => {
const newObj = {} as T;
export const omitUndefinedAndEmptyArr = <T extends Record<string, any>>(
obj: T,
): T => {
const newObj = {} as Record<string, any> as Record<string, any>;
Object.keys(obj || {}).forEach((key) => {
if (Array.isArray(obj[key]) && obj[key]?.length === 0) {
return;
@ -9,5 +11,5 @@ export const omitUndefinedAndEmptyArr = <T>(obj: T): T => {
}
newObj[key] = obj[key];
});
return newObj;
return newObj as T;
};

View File

@ -33,10 +33,10 @@ const antdFormItemPropsList = [
// eslint-disable-next-line @typescript-eslint/ban-types
export function pickProFormItemProps(props: {}) {
const attrs = {};
const attrs = {} as Record<string, any>;
antdFormItemPropsList.forEach((key) => {
if (props[key] !== undefined) {
attrs[key] = props[key];
if ((props as any)[key] !== undefined) {
attrs[key] = (props as any)[key];
}
});
return attrs;

View File

@ -5,7 +5,7 @@ const proFormProps = `fieldProps isDefaultDom groupProps contentRender submitter
export function pickProProps(props: Record<string, any>) {
const propList = `${proFieldProps} ${proFormProps}`.split(/[\s\n]+/);
const attrs = {};
const attrs = {} as Record<string, any>;
Object.keys(props || {}).forEach((key) => {
if (propList.includes(key)) {
return;

View File

@ -131,7 +131,7 @@ export const transformKeySubmitValue = <T extends object = any>(
const key = parentsKey
? [parentsKey, entityKey].flat(1)
: [entityKey].flat(1);
const itemValue = tempValues[entityKey];
const itemValue = (tempValues as any)[entityKey];
const transformFunction = get(dataFormatMap, key as (number | string)[]);

View File

@ -2,7 +2,7 @@
import { LoadingOutlined } from '@ant-design/icons';
import { useIntl } from '@ant-design/pro-provider';
import type { FormInstance, FormProps } from 'antd';
import { Form, message, Popconfirm } from 'antd';
import { Form, Popconfirm, message } from 'antd';
import type { NamePath } from 'antd/lib/form/interface';
import useLazyKVMap from 'antd/lib/table/hooks/useLazyKVMap';
import type { GetRowKey } from 'antd/lib/table/interface';
@ -208,7 +208,7 @@ export function editableRowByKey<RecordType>(
typeof record === 'object' &&
childrenColumnName in record
) {
dig(record[childrenColumnName] || [], recordKey, eachIndex);
dig((record as any)[childrenColumnName] || [], recordKey, eachIndex);
}
const newRecord = {
...record,
@ -274,7 +274,7 @@ export function editableRowByKey<RecordType>(
if (value.map_row_parentKey && value.map_row_key) {
const { map_row_parentKey, map_row_key, ...rest } = value;
if (kvArrayMap.has(map_row_key)) {
rest[childrenColumnName] = kvArrayMap.get(map_row_key);
(rest as any)[childrenColumnName] = kvArrayMap.get(map_row_key);
}
if (!kvArrayMap.has(map_row_parentKey)) {
kvArrayMap.set(map_row_parentKey, []);
@ -352,7 +352,7 @@ export function SaveEditableAction<T>(
const curValue = get(fields, recordKeyPath as string[]);
set(fields, recordKeyPath as (number | string)[], curValue);
}
const data = isMapEditor ? set({}, namePath, fields, true) : fields;
const data = isMapEditor ? set({}, namePath, fields) : fields;
// 获取数据并保存
const res = await onSave?.(
@ -569,8 +569,11 @@ export function useEditableArray<RecordType>(
recordKeyToString(props.getRowKey(record, -1))?.toString(),
key,
);
if (props.childrenColumnName && record[props.childrenColumnName]) {
loopGetKey(record[props.childrenColumnName], key);
if (
props.childrenColumnName &&
(record as any)[props.childrenColumnName]
) {
loopGetKey((record as any)[props.childrenColumnName], key);
}
});
};

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ type Options = {
skip?: boolean;
};
function demoTest(component: string, options: Options = {}) {
function demoTest(component: string, options?: Options) {
const LINE_STR_COUNT = 20;
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
@ -88,10 +88,10 @@ function demoTest(component: string, options: Options = {}) {
describe(`${component} demos`, () => {
files.forEach((file) => {
let testMethod = options.skip === true ? test.skip : test;
let testMethod = options?.skip === true ? test.skip : test;
if (
Array.isArray(options.skip) &&
options.skip.some((c) => file.includes(c))
Array.isArray(options?.skip) &&
options?.skip.some((c) => file.includes(c))
) {
testMethod = test.skip;
}

View File

@ -801,7 +801,6 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},

View File

@ -1393,7 +1393,6 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},
@ -4365,7 +4364,6 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},

View File

@ -1269,7 +1269,6 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},
@ -2482,7 +2481,6 @@ Done in 9.70s.
\\"strict\\": true,
\\"forceConsistentCasingInFileNames\\": true,
\\"noImplicitReturns\\": true,
\\"suppressImplicitAnyIndexErrors\\": true,
\\"declaration\\": true,
\\"skipLibCheck\\": true
},
@ -3671,7 +3669,6 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},
@ -4220,7 +4217,6 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},

View File

@ -165,7 +165,7 @@ Done in 9.70s.
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},

View File

@ -1912,7 +1912,9 @@ describe('BasicLayout', () => {
const locales = {
'menu.home': '主页',
};
return locales[id] ? locales[id] : (defaultMessage as string);
return locales[id as 'menu.home']
? locales[id as 'menu.home']
: (defaultMessage as string);
}}
/>,
);

View File

@ -433,7 +433,7 @@ describe('settingDrawer.test', () => {
<SettingDrawer
disableUrlParams
onSettingChange={(s) => {
if (s[`${key}Render`] === false) {
if (s[`${key}Render` as 'headerRender'] === false) {
fn(key);
}
}}

View File

@ -69,7 +69,7 @@ export const localStorageMock = (() => {
store[key] = null;
},
clear() {
store = {};
store = {} as Record<string, any>;
},
};
})();

Some files were not shown because too many files have changed in this diff Show More