Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable/TreeTable: stricter generically typed API #2523

Closed
VsevolodGolovanov opened this issue Dec 14, 2021 · 5 comments · Fixed by #3822 or #3825
Closed

DataTable/TreeTable: stricter generically typed API #2523

VsevolodGolovanov opened this issue Dec 14, 2021 · 5 comments · Fixed by #3822 or #3825
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@VsevolodGolovanov
Copy link

VsevolodGolovanov commented Dec 14, 2021

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]

@yigitfindikli yigitfindikli added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Mar 22, 2022
@melloware melloware added Component: Documentation Issue or pull request is related to Documentation Typescript Issue or pull request is *only* related to TypeScript definition and removed Component: Documentation Issue or pull request is related to Documentation labels Apr 15, 2022
@DariusRDev
Copy link
Contributor

image
This would improve the Dev-Experience soo much

@melloware
Copy link
Member

@DerDorius feel free to submit a PR!

DariusRDev added a commit to DariusRDev/primereact that referenced this issue Aug 28, 2022
Added Generics for Dropdown.
Generics have to be also added in:
cascadeselect.d.ts
listbox.d.ts
multiselect.d.ts
selectbutton.d.ts

because of the SelectItemOptionsType
DariusRDev added a commit to DariusRDev/primereact that referenced this issue Aug 28, 2022
DariusRDev added a commit to DariusRDev/primereact that referenced this issue Aug 28, 2022
DariusRDev added a commit to DariusRDev/primereact that referenced this issue Aug 28, 2022
DariusRDev added a commit to DariusRDev/primereact that referenced this issue Aug 28, 2022
DariusRDev added a commit to DariusRDev/primereact that referenced this issue Aug 28, 2022
@melloware
Copy link
Member

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

melloware pushed a commit that referenced this issue Aug 28, 2022
…ct, Selectbutton (#3199)

* DataTable/TreeTable: stricter generically typed API #2523
Added Generics for Dropdown.
Generics have to be also added in:
cascadeselect.d.ts
listbox.d.ts
multiselect.d.ts
selectbutton.d.ts

because of the SelectItemOptionsType

* #2523 Add Generics to Select Button

* #2523 select button generics

* #2523 Add Generics to CascadeSelect

* #2523 add generics to List Box

* #2523 Add Multiselect Generics
@diamanthaxhimusa
Copy link

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

@melloware
Copy link
Member

Yes please!

bu3alwa added a commit to bu3alwa/primereact that referenced this issue Dec 24, 2022
bu3alwa added a commit to bu3alwa/primereact that referenced this issue Dec 24, 2022
@melloware melloware added this to the 8.7.4 milestone Dec 25, 2022
melloware added a commit to melloware/primereact that referenced this issue Dec 26, 2022
melloware pushed a commit that referenced this issue Dec 27, 2022
* Fix: #2523 DataTable/TreeTable: stricter generically typed API

* Fix: #2523 DataTable/TreeTable: stricter generically typed API

* Fix: DataTableCellClassNameOptions to correct type

* Fix: more strict types on anys
melloware added a commit to melloware/primereact that referenced this issue Dec 27, 2022
melloware added a commit to melloware/primereact that referenced this issue Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
5 participants