# Types for react-table v7 These types depend upon declaration merging to work well. To get started, create a file `react-table-config.d.ts` using the example further down this readme, place it in your source tree (e.g. into a types folder). This expands the default types with all of the plugin extensions currently in the type definitions. You can stop here if you like, but while this is simple, it's a bit misleading. Out of the box, these types will suggest that you have access to values that come from plugins that you aren't using, i.e. the error checking is substantially weakened. To bring the resulting types into better alignment with your plugins, you should edit your local copy of `react-table-config.d.ts` and remove all of the interfaces that don't apply to your chosen set of plugins. e.g. if you are only using `useSortBy` and `usePagination` then you would take this: ```tsx extends UseExpandedOptions, UseFiltersOptions, UseGroupByOptions, UsePaginationOptions, UseRowSelectOptions, UseSortByOptions, UseFiltersOptions, UseResizeColumnsOptions, Record {} ``` and convert it to this: ```tsx export interface TableOptions extends UsePaginationOptions, UseSortByOptions {} ``` Then follow the same pattern for all of the other interfaces in the file. You'll notice that many plugins don't extend all of the top-level interfaces. ## Caveat The interfaces are all global. If you have several different configurations for the table, you should create interfaces using the union of all of the plugins that you are using. ## Example type file react-table-config.d.ts ```ts import { UseColumnOrderInstanceProps, UseColumnOrderState, UseExpandedHooks, UseExpandedInstanceProps, UseExpandedOptions, UseExpandedRowProps, UseExpandedState, UseFiltersColumnOptions, UseFiltersColumnProps, UseFiltersInstanceProps, UseFiltersOptions, UseFiltersState, UseGlobalFiltersInstanceProps, UseGlobalFiltersOptions, UseGlobalFiltersState, UseGroupByCellProps, UseGroupByColumnOptions, UseGroupByColumnProps, UseGroupByHooks, UseGroupByInstanceProps, UseGroupByOptions, UseGroupByRowProps, UseGroupByState, UsePaginationInstanceProps, UsePaginationOptions, UsePaginationState, UseResizeColumnsColumnOptions, UseResizeColumnsColumnProps, UseResizeColumnsOptions, UseResizeColumnsState, UseRowSelectHooks, UseRowSelectInstanceProps, UseRowSelectOptions, UseRowSelectRowProps, UseRowSelectState, UseRowStateCellProps, UseRowStateInstanceProps, UseRowStateOptions, UseRowStateRowProps, UseRowStateState, UseSortByColumnOptions, UseSortByColumnProps, UseSortByHooks, UseSortByInstanceProps, UseSortByOptions, UseSortByState } from 'react-table' declare module 'react-table' { // take this file as-is, or comment out the sections that don't apply to your plugin configuration export interface TableOptions extends UseExpandedOptions, UseFiltersOptions, UseGlobalFiltersOptions, UseGroupByOptions, UsePaginationOptions, UseResizeColumnsOptions, UseRowSelectOptions, UseRowStateOptions, UseSortByOptions, // note that having Record here allows you to add anything to the options, this matches the spirit of the // underlying js library, but might be cleaner if it's replaced by a more specific type that matches your // feature set, this is a safe default. Record {} export interface Hooks extends UseExpandedHooks, UseGroupByHooks, UseRowSelectHooks, UseSortByHooks {} export interface TableInstance extends UseColumnOrderInstanceProps, UseExpandedInstanceProps, UseFiltersInstanceProps, UseGlobalFiltersInstanceProps, UseGroupByInstanceProps, UsePaginationInstanceProps, UseRowSelectInstanceProps, UseRowStateInstanceProps, UseSortByInstanceProps {} export interface TableState extends UseColumnOrderState, UseExpandedState, UseFiltersState, UseGlobalFiltersState, UseGroupByState, UsePaginationState, UseResizeColumnsState, UseRowSelectState, UseRowStateState, UseSortByState {} export interface Column extends UseFiltersColumnOptions, UseGroupByColumnOptions, UseResizeColumnsColumnOptions, UseSortByColumnOptions {} export interface ColumnInstance extends UseFiltersColumnProps, UseGroupByColumnProps, UseResizeColumnsColumnProps, UseSortByColumnProps {} export interface Cell extends UseGroupByCellProps, UseRowStateCellProps {} export interface Row extends UseExpandedRowProps, UseGroupByRowProps, UseRowSelectRowProps, UseRowStateRowProps {} } ```