-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGrid] Add support for generic types in GridRowParams
, GridCellParams
, GridRenderCellParams
#2436
[DataGrid] Add support for generic types in GridRowParams
, GridCellParams
, GridRenderCellParams
#2436
Conversation
This reverts commit 84c1c5b.
GridRowParams
, GridCellParams
, GridRenderCellParams
GridRowParams
, GridCellParams
, GridRenderCellParams
} | ||
|
||
/** | ||
* GridCellParams containing api. | ||
*/ | ||
export interface GridRenderCellParams extends GridCellParams { | ||
export interface GridRenderCellParams<T = any, RowType = any> extends GridCellParams<T, RowType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export interface GridRenderCellParams<T = any, RowType = any> extends GridCellParams<T, RowType> { | |
-export interface GridRenderCellParams<T = any, RowType = any> extends GridCellParams<T, RowType> { | |
+export interface GridRenderCellParams<T extends GridCellValue = GridCellValue, RowType = any> extends GridCellParams<T, RowType> { |
In another PR, we should add the |
I have to still work on fixing the script to correctly generate the correct docs for generic types. Will be working on it. |
Looks like eg: For export interface GridCellParams<
T = GridCellValue,
RowType extends GridRowDefaultData = GridRowDefaultData,
> {
--
--
value: T;
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: T;
/**
* The row model of the row that the current cell belongs to.
*/
row: GridRowModel<RowType>;
--
--
} Script which executes for reference type: The The script is instead generating, Same is happening for other types and for some it is picking only default generic type in the docs. I checked into core repo for reference but there is nothing I can find to help me. @m4theushw Do you have any idea? You can try running |
I added some TS tests and fixed the docs. In the end, I had to use a bunch of |
Thanks @m4theushw for pushing it further. I have also pushed two commits to improve the docs by leveraging generics. |
Exploring generics for some row and cell types.
Related to issue #1329 (maybe closes this?), issue #545
By passing generic types, we can type
value
,formattedValue
,getValue
return type androw
inGridRenderCellParams
.For onRowXXXX handlers, row is typed:
Need early feedback and how we can go further.
TODO:
test_static
is failing. I tried auto generating docs, it created wrong docs with generics. I think we need to support generics in the docs api script.