Browse Source

chore: fix ts errors

pull/11501/head
afc163 9 months ago
parent
commit
4607f6b013
  1. 2
      mock/analysis.mock.ts
  2. 2
      mock/workplace.mock.ts
  3. 2
      package.json
  4. 22
      src/pages/account/center/components/Applications/index.tsx
  5. 18
      src/pages/account/center/components/AvatarList/index.tsx
  6. 2
      src/pages/account/settings/components/base.tsx
  7. 22
      src/pages/dashboard/analysis/components/Charts/MiniProgress/index.tsx
  8. 5
      src/pages/dashboard/analysis/components/Charts/WaterWave/index.tsx
  9. 4
      src/pages/dashboard/analysis/components/NumberInfo/index.style.ts
  10. 4
      src/pages/dashboard/analysis/components/NumberInfo/index.tsx
  11. 6
      src/pages/dashboard/analysis/components/SalesCard.tsx
  12. 7
      src/pages/dashboard/analysis/data.d.ts
  13. 4
      src/pages/dashboard/analysis/index.tsx
  14. 2
      src/pages/dashboard/analysis/utils/Yuan.tsx
  15. 4
      src/pages/dashboard/analysis/utils/utils.ts
  16. 3
      src/pages/dashboard/monitor/components/Charts/WaterWave/index.tsx
  17. 8
      src/pages/dashboard/workplace/components/EditableLinkGroup/index.tsx
  18. 7
      src/pages/dashboard/workplace/data.d.ts
  19. 2
      src/pages/form/advanced-form/index.tsx
  20. 2
      src/pages/form/step-form/index.tsx
  21. 2
      src/pages/list/table-list/index.tsx
  22. 2
      src/pages/table-list/components/UpdateForm.tsx
  23. 3
      src/pages/user/login/login.test.tsx
  24. 6
      src/pages/user/register/index.tsx
  25. 46
      src/pages/user/register/style.style.ts
  26. 1
      tsconfig.json

2
mock/analysis.mock.ts

@ -1,6 +1,6 @@
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import type { Request, Response } from 'express'; import type { Request, Response } from 'express';
import type { AnalysisData, DataItem, RadarData } from './data'; import type { AnalysisData, DataItem, RadarData } from '../src/pages/dashboard/analysis/data';
// mock data // mock data
const visitData: DataItem[] = []; const visitData: DataItem[] = [];

2
mock/workplace.mock.ts

@ -1,6 +1,6 @@
import { DataItem } from '@antv/g2plot/esm/interface/config';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import type { Request, Response } from 'express'; import type { Request, Response } from 'express';
import type { DataItem, OfflineDataType } from '../src/pages/dashboard/workplace/data.d';
export type SearchDataType = { export type SearchDataType = {
index: number; index: number;

2
package.json

@ -65,7 +65,7 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"express": "^4.21.1", "express": "^4.21.1",
"gh-pages": "^6.1.1", "gh-pages": "^6.1.1",
"husky": "^9.1.6", "husky": "^9.1.7",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
"lint-staged": "^16.1.2", "lint-staged": "^16.1.2",

22
src/pages/account/center/components/Applications/index.tsx

@ -91,16 +91,18 @@ const Applications: React.FC = () => {
<ShareAltOutlined /> <ShareAltOutlined />
</Tooltip>, </Tooltip>,
<Dropdown <Dropdown
items={[ menu={{
{ items: [
key: '1', {
title: '1st menu item', key: '1',
}, title: '1st menu item',
{ },
key: '2', {
title: '2nd menu item', key: '2',
}, title: '2nd menu item',
]} },
],
}}
key="ellipsis" key="ellipsis"
> >
<EllipsisOutlined /> <EllipsisOutlined />

18
src/pages/account/center/components/AvatarList/index.tsx

@ -20,6 +20,14 @@ export type AvatarListProps = {
| React.ReactElement<AvatarItemProps> | React.ReactElement<AvatarItemProps>
| React.ReactElement<AvatarItemProps>[]; | React.ReactElement<AvatarItemProps>[];
}; };
const avatarSizeToClassName = (styles: any, size?: SizeType | 'mini') =>
classNames(styles.avatarItem, {
[styles.avatarItemLarge]: size === 'large',
[styles.avatarItemSmall]: size === 'small',
[styles.avatarItemMini]: size === 'mini',
});
const Item: React.FC<AvatarItemProps> = ({ const Item: React.FC<AvatarItemProps> = ({
src, src,
size, size,
@ -27,13 +35,7 @@ const Item: React.FC<AvatarItemProps> = ({
onClick = () => {}, onClick = () => {},
}) => { }) => {
const { styles } = useStyles(); const { styles } = useStyles();
const avatarSizeToClassName = (size?: SizeType | 'mini') => const cls = avatarSizeToClassName(styles, size);
classNames(styles.avatarItem, {
[styles.avatarItemLarge]: size === 'large',
[styles.avatarItemSmall]: size === 'small',
[styles.avatarItemMini]: size === 'mini',
});
const cls = avatarSizeToClassName(size);
return ( return (
<li className={cls} onClick={onClick}> <li className={cls} onClick={onClick}>
{tips ? ( {tips ? (
@ -67,7 +69,7 @@ const AvatarList: React.FC<AvatarListProps> & {
}), }),
); );
if (numToShow < numOfChildren) { if (numToShow < numOfChildren) {
const cls = avatarSizeToClassName(size); const cls = avatarSizeToClassName(styles, size);
childrenWithProps.push( childrenWithProps.push(
<li key="exceed" className={cls}> <li key="exceed" className={cls}>
<Avatar <Avatar

2
src/pages/account/settings/components/base.tsx

@ -147,7 +147,6 @@ const BaseView: React.FC = () => {
labelInValue: true, labelInValue: true,
}} }}
name="province" name="province"
className={styles.item}
request={async () => { request={async () => {
return queryProvince().then(({ data }) => { return queryProvince().then(({ data }) => {
return data.map((item) => { return data.map((item) => {
@ -175,7 +174,6 @@ const BaseView: React.FC = () => {
}, },
]} ]}
disabled={!province} disabled={!province}
className={styles.item}
request={async () => { request={async () => {
if (!province?.key) { if (!province?.key) {
return []; return [];

22
src/pages/dashboard/analysis/components/Charts/MiniProgress/index.tsx

@ -1,6 +1,5 @@
import { Tooltip } from 'antd'; import { Tooltip } from 'antd';
import React from 'react'; import React from 'react';
import useStyles from './index.style';
export type MiniProgressProps = { export type MiniProgressProps = {
target: number; target: number;
targetLabel?: string; targetLabel?: string;
@ -16,12 +15,10 @@ const MiniProgress: React.FC<MiniProgressProps> = ({
strokeWidth, strokeWidth,
percent, percent,
}) => { }) => {
const { styles } = useStyles();
return ( return (
<div className={styles.miniProgress}> <div>
<Tooltip title={targetLabel}> <Tooltip title={targetLabel}>
<div <div
className={styles.target}
style={{ style={{
left: target ? `${target}%` : undefined, left: target ? `${target}%` : undefined,
}} }}
@ -38,16 +35,13 @@ const MiniProgress: React.FC<MiniProgressProps> = ({
/> />
</div> </div>
</Tooltip> </Tooltip>
<div className={styles.progressWrap}> <div
<div style={{
className={styles.progress} backgroundColor: color || undefined,
style={{ width: percent ? `${percent}%` : undefined,
backgroundColor: color || undefined, height: strokeWidth || undefined,
width: percent ? `${percent}%` : undefined, }}
height: strokeWidth || undefined, />
}}
/>
</div>
</div> </div>
); );
}; };

5
src/pages/dashboard/analysis/components/Charts/WaterWave/index.tsx

@ -1,5 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import autoHeight from '../autoHeight'; import autoHeight from '../../../../monitor/components/Charts/autoHeight';
/* eslint no-return-assign: 0 */ /* eslint no-return-assign: 0 */
/* eslint no-mixed-operators: 0 */ /* eslint no-mixed-operators: 0 */
@ -188,7 +188,6 @@ class WaterWave extends Component<WaterWaveProps> {
const { percent, title, height = 1 } = this.props; const { percent, title, height = 1 } = this.props;
return ( return (
<div <div
className={styles.waterWave}
ref={(n) => { ref={(n) => {
this.root = n; this.root = n;
}} }}
@ -204,7 +203,6 @@ class WaterWave extends Component<WaterWaveProps> {
}} }}
> >
<canvas <canvas
className={styles.waterWaveCanvasWrapper}
ref={(n) => { ref={(n) => {
this.node = n; this.node = n;
}} }}
@ -213,7 +211,6 @@ class WaterWave extends Component<WaterWaveProps> {
/> />
</div> </div>
<div <div
className={styles.text}
style={{ style={{
width: height, width: height,
}} }}

4
src/pages/dashboard/analysis/components/NumberInfo/index.style.ts

@ -11,7 +11,7 @@ const useStyles = createStyles(({ token }) => {
numberInfoTitle: { numberInfoTitle: {
marginBottom: '16px', marginBottom: '16px',
color: token.colorText, color: token.colorText,
fontSize: token['font-size-lg'], fontSize: token.fontSizeLG,
transition: 'all 0.3s', transition: 'all 0.3s',
}, },
numberInfoSubTitle: { numberInfoSubTitle: {
@ -36,7 +36,7 @@ const useStyles = createStyles(({ token }) => {
subTotal: { subTotal: {
marginRight: '0', marginRight: '0',
color: token.colorTextSecondary, color: token.colorTextSecondary,
fontSize: token['font-size-lg'], fontSize: token.fontSizeLG,
verticalAlign: 'top', verticalAlign: 'top',
}, },
anticon: { anticon: {

4
src/pages/dashboard/analysis/components/NumberInfo/index.tsx

@ -27,8 +27,8 @@ const NumberInfo: React.FC<NumberInfoProps> = ({
const { styles } = useStyles(); const { styles } = useStyles();
return ( return (
<div <div
className={classNames(styles.numberInfo, { className={classNames({
[styles[`numberInfo${theme}`]]: theme, [styles[`numberInfo${theme}` as keyof typeof styles]]: !!theme,
})} })}
{...rest} {...rest}
> >

6
src/pages/dashboard/analysis/components/SalesCard.tsx

@ -1,6 +1,6 @@
import { Column } from '@ant-design/plots'; import { Column } from '@ant-design/plots';
import { Card, Col, DatePicker, Row, Tabs } from 'antd'; import { Card, Col, DatePicker, Row, Tabs } from 'antd';
import type { RangePickerProps } from 'antd/es/date-picker/generatePicker'; import type { RangePickerProps } from 'antd/es/date-picker';
import type dayjs from 'dayjs'; import type dayjs from 'dayjs';
import numeral from 'numeral'; import numeral from 'numeral';
import type { DataItem } from '../data.d'; import type { DataItem } from '../data.d';
@ -29,11 +29,11 @@ const SalesCard = ({
loading, loading,
selectDate, selectDate,
}: { }: {
rangePickerValue: RangePickerProps<dayjs.Dayjs>['value']; rangePickerValue: RangePickerProps['value'];
isActive: (key: TimeType) => string; isActive: (key: TimeType) => string;
salesData: DataItem[]; salesData: DataItem[];
loading: boolean; loading: boolean;
handleRangePickerChange: RangePickerProps<dayjs.Dayjs>['onChange']; handleRangePickerChange: RangePickerProps['onChange'];
selectDate: (key: TimeType) => void; selectDate: (key: TimeType) => void;
}) => { }) => {
const { styles } = useStyles(); const { styles } = useStyles();

7
src/pages/dashboard/analysis/data.d.ts

@ -1,7 +1,6 @@
import { DataItem } from '@antv/g2plot/esm/interface/config'; export interface DataItem {
[field: string]: string | number | number[] | null | undefined;
export { DataItem }; }
export interface VisitDataType { export interface VisitDataType {
x: string; x: string;
y: number; y: number;

4
src/pages/dashboard/analysis/index.tsx

@ -2,7 +2,7 @@ import { EllipsisOutlined } from '@ant-design/icons';
import { GridContent } from '@ant-design/pro-components'; import { GridContent } from '@ant-design/pro-components';
import { useRequest } from '@umijs/max'; import { useRequest } from '@umijs/max';
import { Col, Dropdown, Row } from 'antd'; import { Col, Dropdown, Row } from 'antd';
import type { RangePickerProps } from 'antd/es/date-picker/generatePicker'; import type { RangePickerProps } from 'antd/es/date-picker';
import type { RadioChangeEvent } from 'antd/es/radio'; import type { RadioChangeEvent } from 'antd/es/radio';
import type dayjs from 'dayjs'; import type dayjs from 'dayjs';
import type { FC } from 'react'; import type { FC } from 'react';
@ -19,7 +19,7 @@ import { fakeChartData } from './service';
import useStyles from './style.style'; import useStyles from './style.style';
import { getTimeDistance } from './utils/utils'; import { getTimeDistance } from './utils/utils';
type RangePickerValue = RangePickerProps<dayjs.Dayjs>['value']; type RangePickerValue = RangePickerProps['value'];
type AnalysisProps = { type AnalysisProps = {
dashboardAndanalysis: AnalysisData; dashboardAndanalysis: AnalysisData;
loading: boolean; loading: boolean;

2
src/pages/dashboard/analysis/utils/Yuan.tsx

@ -2,7 +2,7 @@ import React from 'react';
import { yuan } from '../components/Charts'; import { yuan } from '../components/Charts';
/** 减少使用 dangerouslySetInnerHTML */ /** 减少使用 dangerouslySetInnerHTML */
export default class Yuan extends React.Component<{ export default class Yuan extends React.Component<{
children: React.ReactText; children: string | number;
}> { }> {
main: HTMLSpanElement | undefined | null = null; main: HTMLSpanElement | undefined | null = null;

4
src/pages/dashboard/analysis/utils/utils.ts

@ -1,7 +1,7 @@
import type { RangePickerProps } from 'antd/es/date-picker/generatePicker'; import type { RangePickerProps } from 'antd/es/date-picker';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
type RangePickerValue = RangePickerProps<dayjs.Dayjs>['value']; type RangePickerValue = RangePickerProps['value'];
export function fixedZero(val: number) { export function fixedZero(val: number) {
return val * 1 < 10 ? `0${val}` : val; return val * 1 < 10 ? `0${val}` : val;

3
src/pages/dashboard/monitor/components/Charts/WaterWave/index.tsx

@ -188,7 +188,6 @@ class WaterWave extends Component<WaterWaveProps> {
const { percent, title, height = 1 } = this.props; const { percent, title, height = 1 } = this.props;
return ( return (
<div <div
className={styles.waterWave}
ref={(n) => { ref={(n) => {
this.root = n; this.root = n;
}} }}
@ -204,7 +203,6 @@ class WaterWave extends Component<WaterWaveProps> {
}} }}
> >
<canvas <canvas
className={styles.waterWaveCanvasWrapper}
ref={(n) => { ref={(n) => {
this.node = n; this.node = n;
}} }}
@ -213,7 +211,6 @@ class WaterWave extends Component<WaterWaveProps> {
/> />
</div> </div>
<div <div
className={styles.text}
style={{ style={{
width: height, width: height,
}} }}

8
src/pages/dashboard/workplace/components/EditableLinkGroup/index.tsx

@ -14,7 +14,7 @@ type EditableLinkGroupProps = {
}; };
const EditableLinkGroup: React.FC<EditableLinkGroupProps> = (props) => { const EditableLinkGroup: React.FC<EditableLinkGroupProps> = (props) => {
const { styles } = useStyles(); const { styles } = useStyles();
const { links, linkElement, onAdd } = props; const { links = [], linkElement = 'a', onAdd = () => {} } = props;
return ( return (
<div className={styles.linkGroup}> <div className={styles.linkGroup}>
{links.map((link) => {links.map((link) =>
@ -34,9 +34,5 @@ const EditableLinkGroup: React.FC<EditableLinkGroupProps> = (props) => {
</div> </div>
); );
}; };
EditableLinkGroup.defaultProps = {
links: [],
onAdd: () => {},
linkElement: 'a',
};
export default EditableLinkGroup; export default EditableLinkGroup;

7
src/pages/dashboard/workplace/data.d.ts

@ -1,7 +1,6 @@
import { DataItem } from '@antv/g2plot/esm/interface/config'; export interface DataItem {
[field: string]: string | number | number[] | null | undefined;
export { DataItem }; }
export interface TagType { export interface TagType {
key: string; key: string;
label: string; label: string;

2
src/pages/form/advanced-form/index.tsx

@ -95,7 +95,7 @@ const AdvancedForm: FC<Record<string, any>> = () => {
onClick={() => scrollToField(key)} onClick={() => scrollToField(key)}
> >
<CloseCircleOutlined className={styles.errorIcon} /> <CloseCircleOutlined className={styles.errorIcon} />
<div className={styles.errorMessage}>{err.errors[0]}</div> <div>{err.errors[0]}</div>
<div className={styles.errorField}>{fieldLabels[key]}</div> <div className={styles.errorField}>{fieldLabels[key]}</div>
</li> </li>
); );

2
src/pages/form/step-form/index.tsx

@ -82,7 +82,7 @@ const StepForm: React.FC<Record<string, any>> = () => {
receiverMode: 'alipay', receiverMode: 'alipay',
}); });
const [current, setCurrent] = useState(0); const [current, setCurrent] = useState(0);
const formRef = useRef<FormInstance>(); const formRef = useRef<FormInstance>(null);
return ( return (
<PageContainer content="将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。"> <PageContainer content="将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。">
<Card bordered={false}> <Card bordered={false}>

2
src/pages/list/table-list/index.tsx

@ -98,7 +98,7 @@ const TableList: React.FC = () => {
const [updateModalVisible, handleUpdateModalVisible] = const [updateModalVisible, handleUpdateModalVisible] =
useState<boolean>(false); useState<boolean>(false);
const [showDetail, setShowDetail] = useState<boolean>(false); const [showDetail, setShowDetail] = useState<boolean>(false);
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>(null);
const [currentRow, setCurrentRow] = useState<TableListItem>(); const [currentRow, setCurrentRow] = useState<TableListItem>();
const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]); const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]);
/** 国际化配置 */ /** 国际化配置 */

2
src/pages/table-list/components/UpdateForm.tsx

@ -20,7 +20,7 @@ export type FormValueType = {
} & Partial<API.RuleListItem>; } & Partial<API.RuleListItem>;
export type UpdateFormProps = { export type UpdateFormProps = {
trigger?: JSX.Element; trigger?: React.ReactElement<any>;
onOk?: () => void; onOk?: () => void;
values: Partial<API.RuleListItem>; values: Partial<API.RuleListItem>;
}; };

3
src/pages/user/login/login.test.tsx

@ -1,4 +1,5 @@
import { startMock } from '@@/requestRecordMock'; // @ts-ignore
import { startMock } from '@@/requestRecordMock';
import { TestBrowser } from '@@/testBrowser'; import { TestBrowser } from '@@/testBrowser';
import { fireEvent, render } from '@testing-library/react'; import { fireEvent, render } from '@testing-library/react';
import React, { act } from 'react'; import React, { act } from 'react';

6
src/pages/user/register/index.tsx

@ -16,7 +16,7 @@ import type { FC } from 'react';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import type { StateType } from './service'; import type { StateType } from './service';
import { fakeRegister } from './service'; import { fakeRegister } from './service';
import useStyles from './style.style'; import useStyles from './styles';
const FormItem = Form.Item; const FormItem = Form.Item;
const { Option } = Select; const { Option } = Select;
@ -135,7 +135,9 @@ const Register: FC = () => {
const value = form.getFieldValue('password'); const value = form.getFieldValue('password');
const passwordStatus = getPasswordStatus(); const passwordStatus = getPasswordStatus();
return value?.length ? ( return value?.length ? (
<div className={styles[`progress-${passwordStatus}`]}> <div
className={styles[`progress-${passwordStatus}` as keyof typeof styles]}
>
<Progress <Progress
status={passwordProgressMap[passwordStatus]} status={passwordProgressMap[passwordStatus]}
strokeWidth={6} strokeWidth={6}

46
src/pages/user/register/style.style.ts

@ -1,46 +0,0 @@
import { createStyles } from 'antd-style';
const useStyles = createStyles(({ token }) => {
return {
main: {
width: '368px',
margin: '0 auto',
h3: { marginBottom: '20px', fontSize: '16px' },
},
password: {
marginBottom: '24px',
'.ant-form-item-explain': { display: 'none' },
},
getCaptcha: {
display: 'block',
width: '100%',
},
footer: {
width: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
},
submit: {
width: '50%',
},
success: {
transition: 'color 0.3s',
color: token.colorSuccess,
},
warning: {
transition: 'color 0.3s',
color: token.colorWarning,
},
error: {
transition: 'color 0.3s',
color: token.colorError,
},
'progress-pass > .progress': {
'.ant-progress-bg': { backgroundColor: token.colorWarning },
},
};
});
export default useStyles;

1
tsconfig.json

@ -9,7 +9,6 @@
"strict": true, "strict": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true, "declaration": true,
"skipLibCheck": true, "skipLibCheck": true,
"resolveJsonModule": true, "resolveJsonModule": true,

Loading…
Cancel
Save