Browse Source

- fix ts error (#5145)

- typescript upgrade to 2.2.1
pull/5179/head
ddcat1115 8 years ago
committed by Wei Zhu
parent
commit
7ab95b7eae
  1. 8
      components/affix/index.tsx
  2. 2
      components/back-top/index.tsx
  3. 2
      components/badge/index.tsx
  4. 4
      components/calendar/Header.tsx
  5. 16
      components/grid/row.tsx
  6. 2
      components/input/Search.tsx
  7. 4
      components/mention/index.tsx
  8. 2
      components/pagination/Pagination.tsx
  9. 2
      components/pagination/index.en-US.md
  10. 2
      components/pagination/index.zh-CN.md
  11. 2
      components/tag/CheckableTag.tsx
  12. 4
      package.json

8
components/affix/index.tsx

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

2
components/back-top/index.tsx

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

2
components/badge/index.tsx

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

4
components/calendar/Header.tsx

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

16
components/grid/row.tsx

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

2
components/input/Search.tsx

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

4
components/mention/index.tsx

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

2
components/pagination/Pagination.tsx

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

2
components/pagination/index.en-US.md

@ -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 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 showQuickJumper | determine whether you can jump to a page directly | boolean | false
size | specify the size of `Pagination`, can be set to `small` | string | "" 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) | - showTotal | to display the total number and range | Function(total, range) | -

2
components/pagination/index.zh-CN.md

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

2
components/tag/CheckableTag.tsx

@ -22,7 +22,7 @@ export default class CheckableTag extends React.Component<CheckableTagProps, any
[`${prefixCls}-checkable-checked`]: checked, [`${prefixCls}-checkable-checked`]: checked,
}, className); }, 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} />; return <div {...restProps as any} className={cls} onClick={this.handleClick} />;
} }
} }

4
package.json

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

Loading…
Cancel
Save