mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
Fix implicit any error for List
This commit is contained in:
parent
084b444252
commit
e7042ae541
@ -2,7 +2,7 @@ import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { Col } from '../grid';
|
||||
import { ListGridType } from './index';
|
||||
import { ListGridType, ColumnType } from './index';
|
||||
|
||||
export interface ListItemProps {
|
||||
className?: string;
|
||||
@ -51,8 +51,8 @@ export const Meta = (props: ListItemMetaProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
function getGrid(grid, t) {
|
||||
return grid[t] && Math.floor(24 / grid[t]);
|
||||
function getGrid(grid: ListGridType, t: ColumnType) {
|
||||
return grid[t] && Math.floor(24 / grid[t]!);
|
||||
}
|
||||
|
||||
const GridColumns = ['', 1, 2, 3, 4, 6, 8, 12, 24];
|
||||
@ -99,7 +99,7 @@ export default class Item extends React.Component<ListItemProps, any> {
|
||||
|
||||
let actionsContent;
|
||||
if (actions && actions.length > 0) {
|
||||
const actionsContentItem = (action, i) => (
|
||||
const actionsContentItem = (action: React.ReactNode, i: number) => (
|
||||
<li key={`${prefixCls}-item-action-${i}`}>
|
||||
{action}
|
||||
{i !== (actions.length - 1) && <em className={`${prefixCls}-item-action-split`}/>}
|
||||
|
@ -12,16 +12,18 @@ import Item from './Item';
|
||||
|
||||
export { ListItemProps, ListItemMetaProps } from './Item';
|
||||
|
||||
export type ColumnType = 1 | 2 | 3 | 4 | 6 | 8 | 12 | 24;
|
||||
export type ColumnCount = 1 | 2 | 3 | 4 | 6 | 8 | 12 | 24;
|
||||
|
||||
export type ColumnType = 'gutter' | 'column' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
||||
|
||||
export interface ListGridType {
|
||||
gutter?: number;
|
||||
column?: ColumnType;
|
||||
xs?: ColumnType;
|
||||
sm?: ColumnType;
|
||||
md?: ColumnType;
|
||||
lg?: ColumnType;
|
||||
xl?: ColumnType;
|
||||
column?: ColumnCount;
|
||||
xs?: ColumnCount;
|
||||
sm?: ColumnCount;
|
||||
md?: ColumnCount;
|
||||
lg?: ColumnCount;
|
||||
xl?: ColumnCount;
|
||||
}
|
||||
|
||||
export type ListSize = 'small' | 'default' | 'large';
|
||||
@ -48,6 +50,10 @@ export interface ListProps {
|
||||
locale?: Object;
|
||||
}
|
||||
|
||||
export interface ListLocale {
|
||||
emptyText: string;
|
||||
}
|
||||
|
||||
export default class List extends React.Component<ListProps> {
|
||||
static Item: typeof Item = Item;
|
||||
|
||||
@ -64,7 +70,7 @@ export default class List extends React.Component<ListProps> {
|
||||
pagination: false,
|
||||
};
|
||||
|
||||
private keys = {};
|
||||
private keys: {[key: string]: string} = {};
|
||||
|
||||
getChildContext() {
|
||||
return {
|
||||
@ -72,7 +78,7 @@ export default class List extends React.Component<ListProps> {
|
||||
};
|
||||
}
|
||||
|
||||
renderItem = (item, index) => {
|
||||
renderItem = (item: React.ReactElement<any>, index: number) => {
|
||||
const { dataSource, renderItem, rowKey } = this.props;
|
||||
let key;
|
||||
|
||||
@ -98,7 +104,7 @@ export default class List extends React.Component<ListProps> {
|
||||
return !!(loadMore || pagination || footer);
|
||||
}
|
||||
|
||||
renderEmpty = (contextLocale) => {
|
||||
renderEmpty = (contextLocale: ListLocale) => {
|
||||
const locale = { ...contextLocale, ...this.props.locale };
|
||||
return <div className={`${this.props.prefixCls}-empty-text`}>{locale.emptyText}</div>;
|
||||
}
|
||||
@ -155,8 +161,8 @@ export default class List extends React.Component<ListProps> {
|
||||
|
||||
let childrenContent;
|
||||
if (dataSource.length > 0) {
|
||||
const childrenList = React.Children.map(dataSource.map((item: any, index) => this.renderItem(item, index)),
|
||||
(child: any, index) => React.cloneElement(child, {
|
||||
const items = dataSource.map((item: any, index: number) => this.renderItem(item, index));
|
||||
const childrenList = React.Children.map(items, (child: any, index) => React.cloneElement(child, {
|
||||
key: this.keys[index],
|
||||
}),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user