Skip to content

Commit 0b8b9db

Browse files
committed
update type
1 parent d3af8c6 commit 0b8b9db

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/Footer/Cell.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,14 @@ import SummaryContext from './SummaryContext';
88

99
export interface SummaryCellProps {
1010
className?: string;
11-
children?: React.ReactNode;
1211
index: number;
1312
colSpan?: number;
1413
rowSpan?: number;
1514
align?: AlignType;
1615
}
1716

18-
export default function SummaryCell({
19-
className,
20-
index,
21-
children,
22-
colSpan = 1,
23-
rowSpan,
24-
align,
25-
}: SummaryCellProps) {
17+
const SummaryCell: React.FC<React.PropsWithChildren<SummaryCellProps>> = props => {
18+
const { className, index, children, colSpan = 1, rowSpan, align } = props;
2619
const { prefixCls } = useContext(TableContext, ['prefixCls']);
2720
const { scrollColumnIndex, stickyOffsets, flattenColumns } = React.useContext(SummaryContext);
2821
const lastIndex = index + colSpan - 1;
@@ -48,4 +41,6 @@ export default function SummaryCell({
4841
{...fixedInfo}
4942
/>
5043
);
51-
}
44+
};
45+
46+
export default SummaryCell;

src/Footer/Summary.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ export interface SummaryProps {
99
/**
1010
* Syntactic sugar. Do not support HOC.
1111
*/
12-
const Summary: React.FC<React.PropsWithChildren<SummaryProps>> = ({ children }) => {
13-
return children as React.ReactElement<any>;
12+
const Summary: React.FC<React.PropsWithChildren<SummaryProps>> & {
13+
Row: typeof Row;
14+
Cell: typeof Cell;
15+
} = props => {
16+
const { children } = props;
17+
return children;
1418
};
1519

16-
(Summary as any).Row = Row;
17-
(Summary as any).Cell = Cell;
20+
Summary.Row = Row;
21+
Summary.Cell = Cell;
1822

1923
export default Summary;

src/Table.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ function defaultEmpty() {
191191
return 'No Data';
192192
}
193193

194-
function Table<RecordType extends DefaultRecordType>(
194+
const Table = <RecordType extends DefaultRecordType>(
195195
tableProps: TableProps<RecordType>,
196196
ref: React.Ref<Reference>,
197-
) {
197+
) => {
198198
const props = {
199199
rowKey: 'key',
200200
prefixCls: DEFAULT_PREFIX,
@@ -927,6 +927,8 @@ function Table<RecordType extends DefaultRecordType>(
927927
// Scroll
928928
mergedScrollX,
929929
scrollInfo,
930+
classNames,
931+
styles,
930932

931933
// Table
932934
prefixCls,
@@ -979,7 +981,7 @@ function Table<RecordType extends DefaultRecordType>(
979981
);
980982

981983
return <TableContext.Provider value={TableContextValue}>{fullTable}</TableContext.Provider>;
982-
}
984+
};
983985

984986
export type ForwardGenericTable = (<RecordType extends DefaultRecordType = any>(
985987
props: TableProps<RecordType> & React.RefAttributes<Reference>,
@@ -991,11 +993,12 @@ if (process.env.NODE_ENV !== 'production') {
991993
RefTable.displayName = 'Table';
992994
}
993995

994-
export function genTable(shouldTriggerRender?: CompareProps<typeof Table>) {
996+
export function genTable(shouldTriggerRender?: CompareProps<ForwardGenericTable>) {
995997
return makeImmutable(RefTable, shouldTriggerRender) as ForwardGenericTable;
996998
}
997999

9981000
const ImmutableTable = genTable();
1001+
9991002
type ImmutableTableType = typeof ImmutableTable & {
10001003
EXPAND_COLUMN: typeof EXPAND_COLUMN;
10011004
INTERNAL_HOOKS: typeof INTERNAL_HOOKS;

0 commit comments

Comments
 (0)