DataTable/TreeTable: stricter generically typed API
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]
This would improve the Dev-Experience soo much
@DerDorius feel free to submit a PR!
I figured we could keep DataTable/TreeTable as a separate PR/ticket.
DataTable/TreeTable still need Generics right? Can I submit a PR for this?
Yes please!