From 8feaa32bb3eaa95bd089a846a2498f7257b536a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sun, 3 Dec 2017 14:28:07 +0800 Subject: [PATCH] Support typescript (#341) * fix some errors found during use * fix some errors found during use * Replace "string | React.ReactNode" with React.ReactNode * replace with * as React * remove excess property --- src/components/AvatarList/index.d.ts | 2 +- src/components/Charts/Bar/index.d.ts | 4 ++-- src/components/Charts/ChartCard/index.d.ts | 6 +++--- src/components/Charts/Field/index.d.ts | 6 +++--- src/components/Charts/Gauge/index.d.ts | 4 ++-- src/components/Charts/MiniArea/index.d.ts | 2 +- src/components/Charts/MiniBar/index.d.ts | 2 +- src/components/Charts/MiniProgress/index.d.ts | 6 +++--- src/components/Charts/Pie/index.d.ts | 6 +++--- src/components/Charts/Radar/index.d.ts | 4 ++-- src/components/Charts/TagCloud/index.d.ts | 2 +- src/components/Charts/TimelineChart/index.d.ts | 2 +- src/components/Charts/WaterWave/index.d.ts | 4 ++-- src/components/CountDown/index.d.ts | 2 +- src/components/DescriptionList/index.d.ts | 2 +- src/components/Ellipsis/index.d.ts | 2 +- src/components/Exception/index.d.ts | 4 ++-- src/components/FooterToolbar/index.d.ts | 2 +- src/components/GlobalFooter/index.d.ts | 4 ++-- src/components/HeaderSearch/index.d.ts | 2 +- src/components/NoticeIcon/index.d.ts | 2 +- src/components/NumberInfo/index.d.ts | 15 ++++++++------- src/components/NumberInfo/index.md | 1 + src/components/PageHeader/index.d.ts | 6 +++--- src/components/Result/index.d.ts | 2 +- src/components/TagSelect/index.d.ts | 2 +- src/components/Trend/index.d.ts | 2 +- 27 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/components/AvatarList/index.d.ts b/src/components/AvatarList/index.d.ts index a6ca98ad..6687bf21 100644 --- a/src/components/AvatarList/index.d.ts +++ b/src/components/AvatarList/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface AvatarItemProps { tips: React.ReactNode; src: string; diff --git a/src/components/Charts/Bar/index.d.ts b/src/components/Charts/Bar/index.d.ts index b66ec437..fd2d05de 100644 --- a/src/components/Charts/Bar/index.d.ts +++ b/src/components/Charts/Bar/index.d.ts @@ -1,6 +1,6 @@ -import React from "react"; +import * as React from "react"; export interface BarProps { - title: string | React.ReactNode; + title: React.ReactNode; color?: string; margin?: [number, number, number, number]; height: number; diff --git a/src/components/Charts/ChartCard/index.d.ts b/src/components/Charts/ChartCard/index.d.ts index bb8824b6..21d2be34 100644 --- a/src/components/Charts/ChartCard/index.d.ts +++ b/src/components/Charts/ChartCard/index.d.ts @@ -1,10 +1,10 @@ -import React from "react"; +import * as React from "react"; export interface ChartCardProps { - title: string | React.ReactNode; + title: React.ReactNode; action?: React.ReactNode; total?: React.ReactNode | number; footer?: React.ReactNode; - contentHeight: number; + contentHeight?: number; avatar?: React.ReactNode; } diff --git a/src/components/Charts/Field/index.d.ts b/src/components/Charts/Field/index.d.ts index dfe3e9cc..7fa13282 100644 --- a/src/components/Charts/Field/index.d.ts +++ b/src/components/Charts/Field/index.d.ts @@ -1,7 +1,7 @@ -import React from "react"; +import * as React from "react"; export interface FieldProps { - label: string | React.ReactNode; - value: string | React.ReactNode; + label: React.ReactNode; + value: React.ReactNode; } export default class Field extends React.Component {} diff --git a/src/components/Charts/Gauge/index.d.ts b/src/components/Charts/Gauge/index.d.ts index 2729a75f..7f196aed 100644 --- a/src/components/Charts/Gauge/index.d.ts +++ b/src/components/Charts/Gauge/index.d.ts @@ -1,6 +1,6 @@ -import React from "react"; +import * as React from "react"; export interface GaugeProps { - title: string | React.ReactNode; + title: React.ReactNode; color?: string; height: number; bgColor?: number; diff --git a/src/components/Charts/MiniArea/index.d.ts b/src/components/Charts/MiniArea/index.d.ts index dff1667e..d2f67e4a 100644 --- a/src/components/Charts/MiniArea/index.d.ts +++ b/src/components/Charts/MiniArea/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; // g2已经更新到3.0 // 不带的写了 diff --git a/src/components/Charts/MiniBar/index.d.ts b/src/components/Charts/MiniBar/index.d.ts index 7b7394f4..09bd761f 100644 --- a/src/components/Charts/MiniBar/index.d.ts +++ b/src/components/Charts/MiniBar/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface MiniBarProps { color?: string; height: number; diff --git a/src/components/Charts/MiniProgress/index.d.ts b/src/components/Charts/MiniProgress/index.d.ts index d89000cc..a80b935d 100644 --- a/src/components/Charts/MiniProgress/index.d.ts +++ b/src/components/Charts/MiniProgress/index.d.ts @@ -1,9 +1,9 @@ -import React from "react"; +import * as React from "react"; export interface MiniProgressProps { target: number; color?: string; - strokeWidth: number; - percent: number; + strokeWidth?: number; + percent?: number; } export default class MiniProgress extends React.Component< diff --git a/src/components/Charts/Pie/index.d.ts b/src/components/Charts/Pie/index.d.ts index 16ad6a3b..44a465d0 100644 --- a/src/components/Charts/Pie/index.d.ts +++ b/src/components/Charts/Pie/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface PieProps { animate?: boolean; color?: string; @@ -11,10 +11,10 @@ export interface PieProps { y: number; }>; total?: string; - title?: string | React.ReactNode; + title?: React.ReactNode; tooltip?: boolean; valueFormat?: (value: string) => string; - subTitle?: string | React.ReactNode; + subTitle?: React.ReactNode; } export default class Pie extends React.Component {} diff --git a/src/components/Charts/Radar/index.d.ts b/src/components/Charts/Radar/index.d.ts index 18c056d3..fa859785 100644 --- a/src/components/Charts/Radar/index.d.ts +++ b/src/components/Charts/Radar/index.d.ts @@ -1,6 +1,6 @@ -import React from "react"; +import * as React from "react"; export interface RadarProps { - title?: string | React.ReactNode; + title?: React.ReactNode; height: number; margin?: [number, number, number, number]; hasLegend?: boolean; diff --git a/src/components/Charts/TagCloud/index.d.ts b/src/components/Charts/TagCloud/index.d.ts index 04c2c250..e7832132 100644 --- a/src/components/Charts/TagCloud/index.d.ts +++ b/src/components/Charts/TagCloud/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface TagCloudProps { data: Array<{ name: string; diff --git a/src/components/Charts/TimelineChart/index.d.ts b/src/components/Charts/TimelineChart/index.d.ts index d03e839c..5ea76a11 100644 --- a/src/components/Charts/TimelineChart/index.d.ts +++ b/src/components/Charts/TimelineChart/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface TimelineChartProps { data: Array<{ x: string; diff --git a/src/components/Charts/WaterWave/index.d.ts b/src/components/Charts/WaterWave/index.d.ts index 258a5670..0fefbea1 100644 --- a/src/components/Charts/WaterWave/index.d.ts +++ b/src/components/Charts/WaterWave/index.d.ts @@ -1,6 +1,6 @@ -import React from "react"; +import * as React from "react"; export interface WaterWaveProps { - title: string | React.ReactNode; + title: React.ReactNode; color?: string; height: number; percent: number; diff --git a/src/components/CountDown/index.d.ts b/src/components/CountDown/index.d.ts index b91c812e..3c46ac79 100644 --- a/src/components/CountDown/index.d.ts +++ b/src/components/CountDown/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface CountDownProps { format?: (time: number) => void; target: Date | number; diff --git a/src/components/DescriptionList/index.d.ts b/src/components/DescriptionList/index.d.ts index c2d75ee2..b13c6301 100644 --- a/src/components/DescriptionList/index.d.ts +++ b/src/components/DescriptionList/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface DescriptionListProps { layout?: "horizontal" | "vertical"; col?: number; diff --git a/src/components/Ellipsis/index.d.ts b/src/components/Ellipsis/index.d.ts index 91446707..66f1de3e 100644 --- a/src/components/Ellipsis/index.d.ts +++ b/src/components/Ellipsis/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface EllipsisProps { tooltip?: boolean; length?: number; diff --git a/src/components/Exception/index.d.ts b/src/components/Exception/index.d.ts index c966a00a..def4034e 100644 --- a/src/components/Exception/index.d.ts +++ b/src/components/Exception/index.d.ts @@ -1,11 +1,11 @@ -import React from "react"; +import * as React from "react"; export interface ExceptionProps { type?: "403" | "404" | "500"; title?: React.ReactNode; desc?: React.ReactNode; img?: string; actions?: React.ReactNode; - linkElement?: string | React.ReactNode; + linkElement?: React.ReactNode; } export default class Exception extends React.Component {} diff --git a/src/components/FooterToolbar/index.d.ts b/src/components/FooterToolbar/index.d.ts index 14f02755..2bc13358 100644 --- a/src/components/FooterToolbar/index.d.ts +++ b/src/components/FooterToolbar/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface FooterToolbarProps { extra: React.ReactNode; } diff --git a/src/components/GlobalFooter/index.d.ts b/src/components/GlobalFooter/index.d.ts index 7f6c7dd3..26f0c115 100644 --- a/src/components/GlobalFooter/index.d.ts +++ b/src/components/GlobalFooter/index.d.ts @@ -1,7 +1,7 @@ -import React from "react"; +import * as React from "react"; export interface GlobalFooterProps { links: Array<{ - title: string | React.ReactNode; + title: React.ReactNode; href: string; blankTarget?: boolean; }>; diff --git a/src/components/HeaderSearch/index.d.ts b/src/components/HeaderSearch/index.d.ts index 69cff7af..2587891d 100644 --- a/src/components/HeaderSearch/index.d.ts +++ b/src/components/HeaderSearch/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface HeaderSearchProps { placeholder?: string; dataSource?: Array; diff --git a/src/components/NoticeIcon/index.d.ts b/src/components/NoticeIcon/index.d.ts index 6bf9dd56..b35c1624 100644 --- a/src/components/NoticeIcon/index.d.ts +++ b/src/components/NoticeIcon/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface NoticeIconData { avatar: string; title: React.ReactNode; diff --git a/src/components/NumberInfo/index.d.ts b/src/components/NumberInfo/index.d.ts index c4c4c4f7..e0b7e5a5 100644 --- a/src/components/NumberInfo/index.d.ts +++ b/src/components/NumberInfo/index.d.ts @@ -1,11 +1,12 @@ -import React from "react"; +import * as React from "react"; export interface NumberInfoProps { - title: React.ReactNode | string; - subTitle: React.ReactNode | string; - total: React.ReactNode | string; - status: "up" | "down"; - theme: string; - gap: number; + title?: React.ReactNode | string; + subTitle?: React.ReactNode | string; + total?: React.ReactNode | string; + status?: "up" | "down"; + theme?: string; + gap?: number; + subTotal?: number; } export default class NumberInfo extends React.Component {} diff --git a/src/components/NumberInfo/index.md b/src/components/NumberInfo/index.md index 8b29c295..1116f990 100644 --- a/src/components/NumberInfo/index.md +++ b/src/components/NumberInfo/index.md @@ -16,6 +16,7 @@ order: 10 title | 标题 | ReactNode\|string | - subTitle | 子标题 | ReactNode\|string | - total | 总量 | ReactNode\|string | - +subTotal | 子总量 | ReactNode\|string | - status | 增加状态 | 'up \| down' | - theme | 状态样式 | string | 'light' gap | 设置数字和描述直接的间距(像素) | number | 8 diff --git a/src/components/PageHeader/index.d.ts b/src/components/PageHeader/index.d.ts index b21fd160..8ca90922 100644 --- a/src/components/PageHeader/index.d.ts +++ b/src/components/PageHeader/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface PageHeaderProps { title?: React.ReactNode | string; logo?: React.ReactNode | string; @@ -6,11 +6,11 @@ export interface PageHeaderProps { content?: React.ReactNode; extraContent?: React.ReactNode; routes?: Array; - params: any; + params?: any; breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>; tabList?: Array<{ key: string; tab: React.ReactNode }>; onTabChange?: (key: string) => void; - linkElement?: string | React.ReactNode; + linkElement?: React.ReactNode; } export default class PageHeader extends React.Component {} diff --git a/src/components/Result/index.d.ts b/src/components/Result/index.d.ts index 6bd31717..c4fef0b3 100644 --- a/src/components/Result/index.d.ts +++ b/src/components/Result/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface ResultProps { type: "success" | "error"; title: React.ReactNode; diff --git a/src/components/TagSelect/index.d.ts b/src/components/TagSelect/index.d.ts index 02580942..516220b6 100644 --- a/src/components/TagSelect/index.d.ts +++ b/src/components/TagSelect/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface TagSelectProps { onChange?: (value: Array) => void; expandable?: boolean; diff --git a/src/components/Trend/index.d.ts b/src/components/Trend/index.d.ts index 6ac7c460..698a49d8 100644 --- a/src/components/Trend/index.d.ts +++ b/src/components/Trend/index.d.ts @@ -1,4 +1,4 @@ -import React from "react"; +import * as React from "react"; export interface TrendProps { colorful?: boolean; -- GitLab