Strongly typed table references
Typing a table instance in adapter or reusable component code.
TanStack · Type Alias
Table<TFeatures, TData> is the TanStack Table instance type. It combines core table behavior with the APIs contributed by the enabled features.
Table<TFeatures, TData> combines core table behavior with the types supplied by enabled features. A table instance is produced by the framework adapter and exposes operations such as retrieving the row model; the generic parameters describe the feature set and row-data shape.
type Table<TFeatures, TData> = Table_Core<TFeatures, TData> & ExtractFeatureMapTypes<TFeatures, Table_FeatureMap<TFeatures, TData>>;| Name | Type | Description |
|---|---|---|
TFeatures | TableFeatures | The enabled table-feature set used to derive feature-specific table members. |
TData | RowData | The shape of data stored in each table row. |
A table instance type containing core functionality plus members derived from enabled features.
Table is an intersection type whose first component is the core table type.import { createColumnHelper, getCoreRowModel, useReactTable } from '@tanstack/react-table'
type Person = { name: string; age: number }
const data: Person[] = [{ name: 'Ada', age: 36 }]
const columnHelper = createColumnHelper<Person>()
const columns = [columnHelper.accessor('name', { header: 'Name' })]
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
})
const allRows = table.getRowModel().rowsCreates a table instance and reads its current row model.
Typing a table instance in adapter or reusable component code.
Accessing core operations and feature APIs from a created table.
Propagating row-data types into table-related APIs.
Table type alias combine?Table<TFeatures, TData> is an intersection of Table_Core<TFeatures, TData> and ExtractFeatureMapTypes<TFeatures, Table_FeatureMap<TFeatures, TData>>. This gives the instance its core API plus the type contributions from enabled features.
Follow-up: Why use feature extraction? It lets the table type expose only the feature-related members associated with the generic feature set.
TFeatures describes the table's feature configuration, while TData describes the row-data type. Both are carried through the core and feature-derived portions of the alias.
Follow-up: How would a row-specific API become type-safe? Bind TData to the row interface used by the table's data and column definitions.
Table value represent?The documentation describes Table as the table object containing core functionality and enabled features. In application code, an adapter-created table instance is the value consumed to access table operations such as its row model.
Follow-up: What should be checked when a feature method is missing? Verify that the feature is enabled and included in the table's generic feature set.
Table_CoreTable_FeatureMapTableFeaturesRowDatauseReactTablegetCoreRowModel