Skip to content

Commit

Permalink
fix ts interface error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali committed Jun 20, 2023
1 parent 5d65881 commit d30050f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion components/progress/index.en-US.md
Expand Up @@ -50,7 +50,7 @@ Properties that shared by all types.
| success | Configs of successfully progress bar | { percent: number, strokeColor: string } | - | - |
| trailColor | The color of unfilled part | string | - | - |
| type | To set the type, options: `line` `circle` `dashboard` | string | `line` |
| size | Progress size | number \| \[number, number] \| "small" \| "default" | "default" | v5.3.0 |
| size | Progress size | number \| \[number \| string, number] \| "small" \| "default" | "default" | v5.3.0 |

### `type="line"`

Expand Down
2 changes: 1 addition & 1 deletion components/progress/index.zh-CN.md
Expand Up @@ -51,7 +51,7 @@ demo:
| success | 成功进度条相关配置 | { percent: number, strokeColor: string } | - | - |
| trailColor | 未完成的分段的颜色 | string | - | - |
| type | 类型,可选 `line` `circle` `dashboard` | string | `line` | - |
| size | 进度条的尺寸 | number \| \[number, number] \| "small" \| "default" | "default" | v5.3.0 |
| size | 进度条的尺寸 | number \| \[number \| string, number] \| "small" \| "default" | "default" | v5.3.0 |

### `type="line"`

Expand Down
2 changes: 1 addition & 1 deletion components/progress/progress.tsx
Expand Up @@ -50,7 +50,7 @@ export interface ProgressProps extends ProgressAriaProps {
style?: React.CSSProperties;
gapDegree?: number;
gapPosition?: 'top' | 'bottom' | 'left' | 'right';
size?: number | [number, number] | ProgressSize;
size?: number | [number | string, number] | ProgressSize;
steps?: number;
/** @deprecated Use `success` instead */
successPercent?: number;
Expand Down
20 changes: 10 additions & 10 deletions components/progress/utils.ts
@@ -1,7 +1,7 @@
import { presetPrimaryColors } from '@ant-design/colors';
import warning from '../_util/warning';
import type { CircleProps } from './Circle';
import type { ProgressProps } from './progress';
import warning from '../_util/warning';

export function validProgress(progress?: number) {
if (!progress || progress < 0) {
Expand Down Expand Up @@ -35,10 +35,10 @@ export const getPercentage = ({ percent, success, successPercent }: ProgressProp
return [realSuccessPercent, validProgress(validProgress(percent) - realSuccessPercent)];
};

export const getStrokeColor = ({ success = {}, strokeColor }: Partial<CircleProps>): (
| string
| Record<PropertyKey, string>
)[] => {
export const getStrokeColor = ({
success = {},
strokeColor,
}: Partial<CircleProps>): (string | Record<PropertyKey, string>)[] => {
const { strokeColor: successColor } = success;
return [successColor || presetPrimaryColors.green, strokeColor || null!];
};
Expand All @@ -50,9 +50,9 @@ export const getSize = (
steps?: number;
strokeWidth?: number;
},
): [number, number] => {
let width: number = -1;
let height: number = -1;
): [number | string, number | string] => {
let width: number | string = -1;
let height: number | string = -1;
if (type === 'step') {
const steps = extra!.steps!;
const strokeWidth = extra!.strokeWidth!;
Expand All @@ -62,7 +62,7 @@ export const getSize = (
} else if (typeof size === 'number') {
[width, height] = [size, size];
} else {
[width = 14, height = 8] = size;
[width = 14, height = 8] = size as [number, number];
}
width *= steps;
} else if (type === 'line') {
Expand All @@ -72,7 +72,7 @@ export const getSize = (
} else if (typeof size === 'number') {
[width, height] = [size, size];
} else {
[width = -1, height = 8] = size;
[width = -1, height = 8] = size as [number, number];
}
} else if (type === 'circle' || type === 'dashboard') {
if (typeof size === 'string' || typeof size === 'undefined') {
Expand Down

0 comments on commit d30050f

Please sign in to comment.