- fix ts error (#5145)

- typescript upgrade to 2.2.1
This commit is contained in:
ddcat1115 2017-03-06 15:48:03 +08:00 committed by Wei Zhu
parent a7a4d672f5
commit 7ab95b7eae
12 changed files with 26 additions and 24 deletions

View File

@ -138,12 +138,12 @@ export default class Affix extends React.Component<AffixProps, any> {
const targetRect = getTargetRect(targetNode);
const targetInnerHeight =
(targetNode as Window).innerHeight || (targetNode as HTMLElement).clientHeight;
if (scrollTop > elemOffset.top - offsetTop && offsetMode.top) {
if (scrollTop > elemOffset.top - (offsetTop as number) && offsetMode.top) {
// Fixed Top
const width = elemOffset.width;
this.setAffixStyle(e, {
position: 'fixed',
top: targetRect.top + offsetTop,
top: targetRect.top + (offsetTop as number),
left: targetRect.left + elemOffset.left,
width,
});
@ -152,7 +152,7 @@ export default class Affix extends React.Component<AffixProps, any> {
height: affixNode.offsetHeight,
});
} else if (
scrollTop < elemOffset.top + elemSize.height + offsetBottom - targetInnerHeight &&
scrollTop < elemOffset.top + elemSize.height + (offsetBottom as number) - targetInnerHeight &&
offsetMode.bottom
) {
// Fixed Bottom
@ -160,7 +160,7 @@ export default class Affix extends React.Component<AffixProps, any> {
const width = elemOffset.width;
this.setAffixStyle(e, {
position: 'fixed',
bottom: targetBottomOffet + offsetBottom,
bottom: targetBottomOffet + (offsetBottom as number),
left: targetRect.left + elemOffset.left,
width,
});

View File

@ -82,7 +82,7 @@ export default class BackTop extends React.Component<BackTopProps, any> {
const { visibilityHeight, target = getDefaultTarget } = this.props;
const scrollTop = getScroll(target(), true);
this.setState({
visible: scrollTop > visibilityHeight,
visible: scrollTop > (visibilityHeight as number),
});
}

View File

@ -53,7 +53,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
...restProps,
} = this.props;
const isDot = dot || status;
let displayCount = count > overflowCount ? `${overflowCount}+` : count;
let displayCount = count > (overflowCount as number) ? `${overflowCount}+` : count;
// dot mode don't need count
if (isDot) {
displayCount = '';

View File

@ -26,8 +26,8 @@ export default class Header extends React.Component<HeaderProps, any> {
getYearSelectElement(year) {
const { yearSelectOffset, yearSelectTotal, locale, prefixCls, fullscreen } = this.props;
const start = year - yearSelectOffset;
const end = start + yearSelectTotal;
const start = year - (yearSelectOffset as number);
const end = start + (yearSelectTotal as number);
const suffix = locale.year === '年' ? '年' : '';
const options: React.ReactElement<any>[] = [];

View File

@ -17,6 +17,7 @@ export default class Row extends React.Component<RowProps, any> {
static defaultProps = {
gutter: 0,
};
static propTypes = {
type: React.PropTypes.string,
align: React.PropTypes.string,
@ -27,16 +28,17 @@ export default class Row extends React.Component<RowProps, any> {
prefixCls: React.PropTypes.string,
};
render() {
const { type, justify, align, className, gutter, style, children, prefixCls = 'ant-row', ...others } = this.props;
const { type, justify, align, className, gutter, style, children,
prefixCls = 'ant-row', ...others } = this.props;
const classes = classNames({
[prefixCls]: !type,
[`${prefixCls}-${type}`]: type,
[`${prefixCls}-${type}-${justify}`]: type && justify,
[`${prefixCls}-${type}-${align}`]: type && align,
}, className);
const rowStyle = gutter > 0 ? assign({}, {
marginLeft: gutter / -2,
marginRight: gutter / -2,
const rowStyle = (gutter as number) > 0 ? assign({}, {
marginLeft: (gutter as number) / -2,
marginRight: (gutter as number) / -2,
}, style) : style;
const cols = Children.map(children, (col: React.ReactElement<any>) => {
if (!col) {
@ -44,9 +46,9 @@ export default class Row extends React.Component<RowProps, any> {
}
if (col.props) {
return cloneElement(col, {
style: gutter > 0 ? assign({}, {
paddingLeft: gutter / 2,
paddingRight: gutter / 2,
style: (gutter as number) > 0 ? assign({}, {
paddingLeft: (gutter as number) / 2,
paddingRight: (gutter as number) / 2,
}, col.props.style) : col.props.style,
});
}

View File

@ -32,7 +32,7 @@ export default class Search extends React.Component<SearchProps, any> {
}
render() {
const { className, prefixCls, ...others } = this.props;
delete others.onSearch;
delete (others as any).onSearch;
const searchSuffix = (
<Icon
className={`${prefixCls}-icon`}

View File

@ -6,13 +6,13 @@ import Icon from '../icon';
export interface MentionProps {
prefixCls: string;
suggestionStyle?: Object;
suggestionStyle?: React.CSSProperties;
suggestions?: Array<any>;
onSearchChange?: Function;
onChange?: Function;
notFoundContent?: any;
loading?: Boolean;
style?: Object;
style?: React.CSSProperties;
defaultValue?: any;
value?: any;
className?: string;

View File

@ -28,7 +28,7 @@ export interface PaginationProps {
/** 当为「small」时是小尺寸分页 */
size?: string;
/** 当添加该属性时,显示为简单分页*/
simple?: Object;
simple?: boolean;
/** 用于显示总共有多少条数据*/
showTotal?: (total: number) => React.ReactNode;
style?: React.CSSProperties;

View File

@ -31,5 +31,5 @@ pageSizeOptions | specify the sizeChanger selections | string[] | ['10', '20', '
onShowSizeChange | a callback function, can be executed when `pageSize` is changing | Function(current, size) | noop
showQuickJumper | determine whether you can jump to a page directly | boolean | false
size | specify the size of `Pagination`, can be set to `small` | string | ""
simple | whether to use simple mode | object | -
simple | whether to use simple mode | boolean | -
showTotal | to display the total number and range | Function(total, range) | -

View File

@ -32,5 +32,5 @@ cols: 1
| onShowSizeChange | pageSize 变化的回调 | Function(current, size) | noop |
| showQuickJumper | 是否可以快速跳转至某页 | boolean | false |
| size | 当为「small」时是小尺寸分页 | string | "" |
| simple | 当添加该属性时,显示为简单分页 | object | - |
| simple | 当添加该属性时,显示为简单分页 | boolean | - |
| showTotal | 用于显示数据总量和当前数据顺序 | Function(total, range) | - |

View File

@ -22,7 +22,7 @@ export default class CheckableTag extends React.Component<CheckableTagProps, any
[`${prefixCls}-checkable-checked`]: checked,
}, className);
delete restProps.onChange; // TypeScript cannot check delete now.
delete (restProps as any).onChange; // TypeScript cannot check delete now.
return <div {...restProps as any} className={cls} onClick={this.handleClick} />;
}
}

View File

@ -78,7 +78,7 @@
"@types/react": "^15.0.8",
"@types/react-dom": "~0.14.18",
"antd-demo-jest": "^1.0.5",
"antd-tools": "~0.16.0",
"antd-tools": "~0.18.0",
"babel-cli": "^6.18.0",
"babel-eslint": "^7.1.0",
"babel-jest": "^17.0.0",
@ -133,7 +133,7 @@
"rimraf": "^2.5.4",
"stylelint": "^7.8.0",
"stylelint-config-standard": "^16.0.0",
"typescript": "~2.1.6",
"typescript": "~2.2.1",
"typescript-babel-jest": "^0.1.5",
"values.js": "^1.0.3",
"xhr2": "^0.1.3"