diff --git a/types/carbon-components-react/carbon-components-react-tests.tsx b/types/carbon-components-react/carbon-components-react-tests.tsx index db78811a37..87db4e8875 100644 --- a/types/carbon-components-react/carbon-components-react-tests.tsx +++ b/types/carbon-components-react/carbon-components-react-tests.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { AccordionItem, DataTable, + DataTableCustomRenderProps, DataTableHeader, DataTableRow, Slider, @@ -169,6 +170,63 @@ const t4 = ( }} /> ); +// RenderProps are compatible with sub-elements +interface T5RowType extends DataTableRow { + col1: number; + col2: number; +} +const t5RowItems: T5RowType[] = [ + { id: "row0", col1: 0, col2: 0}, + { id: "row1", col1: 1, col2: 1}, +]; +const t5Headers: DataTableHeader[] = [ + {key: 'col1', header: 'First column'}, + {key: 'col2', header: 'Second column'} +]; +const t5 = ( + ) => ( + + + + + + {renderProps.headers.map(header => ( + + {header.header} + + ))} + + + + + {renderProps.rows.map(row => ( + + + + {row.cells.map(cell => ( + + {cell.value} + + ))} + + + + ))} + + + + )} + /> +); // UIShell - Link interface TestCompProps { diff --git a/types/carbon-components-react/lib/components/DataTable/DataTable.d.ts b/types/carbon-components-react/lib/components/DataTable/DataTable.d.ts index 22bc4ad88d..7977fb858b 100644 --- a/types/carbon-components-react/lib/components/DataTable/DataTable.d.ts +++ b/types/carbon-components-react/lib/components/DataTable/DataTable.d.ts @@ -70,13 +70,13 @@ export interface DataTableCustomSelectionData { ariaLabel?: string, - checked: R extends never ? boolean : R["isSelected"], + checked: R extends never ? boolean : NonNullable, disabled: R extends never ? never : R["disabled"], id: string, indeterminate: R extends never ? boolean : never, name: string, onSelect(event: React.MouseEvent): void, - radio: R extends never ? never : (Extract | null), + radio?: R extends never ? never : (Extract), } // endregion Row Types