chore: fix ts define

This commit is contained in:
zombiej 2019-11-06 11:18:11 +08:00
parent d75d049b5c
commit 9bea463638
5 changed files with 23 additions and 63 deletions

View File

@ -68,13 +68,19 @@ const AutoComplete: React.RefForwardingComponent<Select, AutoCompleteProps> = (p
}
switch (typeof item) {
case 'string':
return <Option key={item}>{item}</Option>;
case 'object':
return (
<Option key={(item as DataSourceItemObject).value}>
<Option key={item} value={item}>
{item}
</Option>
);
case 'object': {
const { value: optionValue } = item as DataSourceItemObject;
return (
<Option key={optionValue} value={optionValue}>
{(item as DataSourceItemObject).text}
</Option>
);
}
default:
throw new Error('AutoComplete[dataSource] only supports type `string[] | Object[]`.');
}

View File

@ -59,7 +59,12 @@ export default class Header extends React.Component<HeaderProps, any> {
const suffix = locale.year === '年' ? '年' : '';
const options: React.ReactElement<any>[] = [];
for (let index = start; index < end; index++) {
options.push(<Option key={`${index}`}>{index + suffix}</Option>);
const optionValue = `${index}`;
options.push(
<Option key={optionValue} value={optionValue}>
{index + suffix}
</Option>,
);
}
return (
<Select
@ -92,7 +97,12 @@ export default class Header extends React.Component<HeaderProps, any> {
}
for (let index = start; index < end; index++) {
options.push(<Option key={`${index}`}>{months[index]}</Option>);
const optionValue = `${index}`;
options.push(
<Option key={optionValue} value={optionValue}>
{months[index]}
</Option>,
);
}
return (
<Select

View File

@ -1,56 +0,0 @@
import * as React from 'react';
import Icon, { IconProps } from './index';
const customCache = new Set<string>();
export interface CustomIconOptions {
scriptUrl?: string;
extraCommonProps?: { [key: string]: any };
}
export default function create(options: CustomIconOptions = {}): React.SFC<IconProps> {
const { scriptUrl, extraCommonProps = {} } = options;
/**
* DOM API required.
* Make sure in browser environment.
* The Custom Icon will create a <script/>
* that loads SVG symbols and insert the SVG Element into the document body.
*/
if (
typeof document !== 'undefined' &&
typeof window !== 'undefined' &&
typeof document.createElement === 'function' &&
typeof scriptUrl === 'string' &&
scriptUrl.length &&
!customCache.has(scriptUrl)
) {
const script = document.createElement('script');
script.setAttribute('src', scriptUrl);
script.setAttribute('data-namespace', scriptUrl);
customCache.add(scriptUrl);
document.body.appendChild(script);
}
const Iconfont: React.SFC<IconProps> = props => {
const { type, children, ...restProps } = props;
// component > children > type
let content = null;
if (props.type) {
content = <use xlinkHref={`#${type}`} />;
}
if (children) {
content = children;
}
return (
<Icon {...extraCommonProps} {...restProps}>
{content}
</Icon>
);
};
Iconfont.displayName = 'Iconfont';
return Iconfont;
}

View File

@ -58,7 +58,7 @@ export function normalizeColumns(elements: React.ReactChildren) {
return;
}
const column: any = {
...element.props,
...(element.props as any),
};
if (element.key) {
column.key = element.key;

View File

@ -124,7 +124,7 @@
"rc-progress": "~2.5.0",
"rc-rate": "~2.5.0",
"rc-resize-observer": "^0.1.0",
"rc-select": "~10.0.0-alpha.28",
"rc-select": "~10.0.0-alpha.29",
"rc-slider": "~8.7.1",
"rc-steps": "~3.5.0",
"rc-switch": "~1.9.0",