primereact icon indicating copy to clipboard operation
primereact copied to clipboard

DataTable/TreeTable: stricter generically typed API

Open VsevolodGolovanov opened this issue 4 years ago • 5 comments

Codesandbox Case (Bug Reports)

Current behavior The Tables have a lot of anys in them:

export interface DataTableProps {
    value?: any[];
    selection?: any | any[];

And many more. any is not just a type - it disables static typing. TS actually recommends not using it all. This makes code using Tables less resilient to PrimeReact update changes, less type safe in general (selection should consist of data entiries, but this is not checked), and makes PrimeReact API harder to understand (e.g. rowClassName and cellClassName both accept the data argument - what is it? You have to run some code to figure that out).

Expected behavior Avoid any and bind associated types with generics. E.g.:

export interface DataTableProps<RowType> {
    value?: RowType[];
    selection?: RowType | RowType[];

Minimal reproduction of the problem with instructions

Please tell us about your environment:

  • React version:

  • PrimeReact version: 7.1.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

VsevolodGolovanov avatar Dec 14 '21 13:12 VsevolodGolovanov

image This would improve the Dev-Experience soo much

DariusRDev avatar Aug 27 '22 13:08 DariusRDev

@DerDorius feel free to submit a PR!

melloware avatar Aug 27 '22 14:08 melloware

I figured we could keep DataTable/TreeTable as a separate PR/ticket.

melloware avatar Aug 28 '22 14:08 melloware

DataTable/TreeTable still need Generics right? Can I submit a PR for this?

diamanthaxhimusa avatar Sep 14 '22 07:09 diamanthaxhimusa

Yes please!

melloware avatar Sep 14 '22 08:09 melloware