-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add typescript docs #1564
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
Add typescript docs #1564
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a5e2a7d:
|
When defining export interface TableOptions<D extends object>
extends UsePaginationOptions<D>,
UseSortByOptions<D> {} How to use it then? Should I also redefine export function useTable<D extends object = {}>(
options: TableOptions<D>,
...plugins: PluginHook<D>[]
): TableInstance<D>; ? |
@simPod You don't have to do anything. I know, it took me a while to get my head around what's happening. All of the type definitions are global, so by extending the definitions of say |
Right, makes sense! But what if... I use different tables with different plugins? Eg. table A uses sorting and table B uses pagination. Then I should type them separately export interface TableOptionsSorted<D extends object> extends UseSortByOptions<D> {} // table A export interface TableOptionsPaginated<D extends object> extends UsePaginationOptions<D> {} // table B |
I mention this in the caveat section, right now you just have to define a
superset type using all of the plugins that you are using.
We just haven’t found a better solution that works yet.
…On Sat, Oct 5, 2019 at 3:36 AM Šimon Podlipský ***@***.***> wrote:
Right, makes sense!
But what if... I use different tables with different plugins? Eg. table A
uses sorting and table B uses pagination. Then I should type them separately
export interface TableOptionsSorted<D extends object> extends UseSortByOptions<D> {} // table A
export interface TableOptionsPaginated<D extends object> extends UsePaginationOptions<D> {} // table B
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1564>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACAVVGBTJ5KDRIHNPHHFITQNBU3JANCNFSM4I42SGDQ>
.
|
I was wondering that we could somehow allow to pass those custom types into Not sure if doable tho, don't have any experience in designing such complex types. export interface TableComposite<D extends object = {}> {
value: D;
options: TableOptions<D>;
instance: TableInstance<D>;
state: TableState<D>;
column: Column<D>;
columnInstance: ColumnInstance<D>;
cell: Cell<D>;
row: Row<D>;
}
...
useTable<TableComposite<MyValueType>>(...) |
@simPod This has already been discussed and explored. Unless you're speaking to extending each type at each instance and pass that to the type. Which I'm unsure if we would run into a similar situation. |
There have been changes to the API around useTableState. Please see the latest commits and release to get up to date. |
UseGroupByCellProps<D>, | ||
UseRowStateCellProps<D> {} | ||
|
||
export interface Row<D extends object = {}> |
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.
I had to add Omit<UseTableRowProps<D>, 'state'>
for I'm using getRowProps
and cells
on Row. Also had to omit state: object
because it's already in UseRowStateRowProps
as state: UseRowStateLocalState<D>
.
export interface Row<D extends object = {}> | |
export interface Row<D extends object = {}> extends UseExpandedRowProps<D>, | |
UseGroupByRowProps<D>, | |
UseRowSelectRowProps<D>, | |
Omit<UseTableRowProps<D>, 'state'>, | |
UseRowStateRowProps<D> { | |
} |
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.
I noticed this as well, and raised this on #1535, though I'm failing to find the comment right now. I'll add it to the list again.
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.
Cool. Everything else works for me (though I have only one table for v7). Thanks!
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.
Trying to determine which state
is correct.
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.
state
only appears to be on row
if you use useRowState
plugin hook. In which, it forks the key rowState
out of state
.
@stramel I think that this addresses your comment from the other PR. |
@stramel @tannerlinsley - is it worth merging this before the next release? |
I think so |
Okie dokie! |
Released! |
This is tied to the type implementation found in #1535.
I'm more than happy if this gets merged into that branch before merging, or whatever's convenient :)