Skip to content

Commit

Permalink
fix: fix availability of RowDataType type (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonguo committed Dec 1, 2023
1 parent a6a9cff commit 8590477
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/@types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type TableSizeChangeEventName =
| 'widthChanged'
| 'heightChanged';

export interface RowDataType<T = never> {
export interface RowDataType<T = any> {
dataKey?: string;
children?: T[];
[key: string]: any;
Expand Down
26 changes: 18 additions & 8 deletions test/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ import React from 'react';
import { expectType } from 'ts-expect';
import Table, { TableInstance } from '../src/Table';
import Cell from '../src/Cell';
import Column from '../src/Column';
import HeaderCell from '../src/HeaderCell';
import { ItemDataType } from 'rsuite/esm/@types/common';

type Row = {
id: number;
name: string;
};

const data: Row[] = [
{
id: 1,
name: 'First'
},
{
id: 2,
name: 'Second'
}
{ id: 1, name: 'First' },
{ id: 2, name: 'Second' }
];

<Table
Expand Down Expand Up @@ -127,3 +124,16 @@ export const ImageCell = <TKey extends string, TRow extends Record<TKey, string>
<img src={rowData[dataKey]} width="50" />
</Cell>
);

const rows: ItemDataType[] = [
{ id: 1, name: 'First' },
{ id: 2, name: 'Second' }
];

// test case for https://github.com/rsuite/rsuite-table/issues/422
<Table data={rows}>
<Column width={50}>
<HeaderCell>Id</HeaderCell>
<Cell>{rowData => rowData.id}</Cell>
</Column>
</Table>;

1 comment on commit 8590477

@vercel
Copy link

@vercel vercel bot commented on 8590477 Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.