TypeScript Types
Every TypeScript type and interface used by the data table.
types.ts holds the TypeScript types used across the data table.
Core Types
Section titled “Core Types”Option
Section titled “Option”An option in a select or multi-select filter.
interface Option { label: string value: string count?: number icon?: React.ComponentType<{ className?: string }>}FilterVariant
Section titled “FilterVariant”Sets which UI control a filter uses.
type FilterVariant = | "text" | "number" | "range" | "date" | "dateRange" | "select" | "multiSelect" | "boolean"FilterOperator
Section titled “FilterOperator”Sets how a filter compares values.
type FilterOperator = | "ilike" | "not.ilike" | "eq" | "neq" | "in" | "not.in" | "empty" | "not.empty" | "lt" | "lte" | "gt" | "gte" | "between" | "relative"JoinOperator
Section titled “JoinOperator”Sets how several filters combine.
type JoinOperator = "and" | "or" | "mixed"Extended Types
Section titled “Extended Types”ExtendedColumnFilter
Section titled “ExtendedColumnFilter”A column filter with extra metadata.
interface ExtendedColumnFilter<TData> { id: Extract<keyof TData, string> value: string | string[] variant: FilterVariant operator: FilterOperator filterId: string joinOperator?: JoinOperator // Individual join operator for each filter}ExtendedColumnSort
Section titled “ExtendedColumnSort”A column sort, used for URL state.
interface ExtendedColumnSort<TData> { id: Extract<keyof TData, string> desc: boolean}GlobalFilter
Section titled “GlobalFilter”The global (search) filter value.
type GlobalFilter = string | Record<string, unknown>Column Definition Types
Section titled “Column Definition Types”DataTableColumnDef
Section titled “DataTableColumnDef”The column definition type. It has every TanStack Table ColumnDef property.
type DataTableColumnDef<TData, TValue = unknown> = ColumnDef< DataTableFeatures, TData, TValue>For static columns, use createDataTableColumnHelper<TData>().
- Same binding: it pre-binds
DataTableFeatures, like this alias. - Typed cells:
getValue()is typed. - Mixed value types: helper results mix per-column value types. Pass them as
DataTableColumns<TData>(whatDataTableRootaccepts). - Plain arrays:
DataTableColumnDef<TData>[]fits dynamic columns and copy-paste examples better.
import { createDataTableColumnHelper } from "@/components/niko-table/lib/data-table-features"
const columnHelper = createDataTableColumnHelper<Product>()const columns = [ columnHelper.accessor("price", { cell: ({ getValue }) => getValue().toFixed(2), }),]DataTableColumns
Section titled “DataTableColumns”The column array type for DataTableRoot. Helper columns each have their own TValue, so they do not fit DataTableColumnDef<TData>[] (its TValue defaults to unknown). Use this alias instead.
type DataTableColumns<TData> = DataTableColumnDef<TData, any>[]ColumnMeta
Section titled “ColumnMeta”Extra column metadata. It adds to TanStack Table’s ColumnMeta.
interface ColumnMeta<TData extends RowData, TValue> { // Display label?: string placeholder?: string
// Filtering variant?: FilterVariant options?: Option[] range?: [number, number] autoOptions?: boolean autoOptionsFormat?: boolean /** Per-column label formatter for auto-derived faceted-filter options. * Wins over `autoOptionsFormat`; ignored when caller passes explicit `options`. */ formatOptionLabel?: (value: string) => string showCounts?: boolean dynamicCounts?: boolean mergeStrategy?: "preserve" | "augment" | "replace"
// Formatting unit?: string icon?: React.ComponentType<{ className?: string }>
// Layout /** Controls which column absorbs leftover row width (flex fill). * Fill is on by default for resizable tables — the first non-pinned, * resizable data column flexes automatically. Set `true` to make THIS * column the one that fills instead of the default; set `false` to opt a * column out of ever being auto-picked. Pure layout — never written to * `columnSizing`. */ flex?: boolean
// Row Expansion expandedContent?: (row: TData) => React.ReactNode}TableMeta
Section titled “TableMeta”Extra table metadata. It adds to TanStack Table’s TableMeta.
interface TableMeta<TData extends RowData> { joinOperator?: JoinOperator hasIndividualJoinOperators?: boolean /** Turns flex fill off for the whole table. Flex fill (the first resizable * data column absorbing leftover row width) is on by default when column * resizing is enabled; set `true` for a wide table meant to scroll * horizontally rather than fill its container. */ disableFlexFill?: boolean}Pass table metadata through the table-level meta option on DataTableRoot, not a column’s meta:
<DataTableRoot data={data} columns={columns} meta={{ disableFlexFill: true }}>disableFlexFill is read when the table options are built. Set it statically, not at runtime.
Row Types
Section titled “Row Types”DataTableRow
Section titled “DataTableRow”A row. Alias for TanStack Table’s Row, bound to DataTable’s features.
type DataTableRow<TData> = Row<DataTableFeatures, TData>DataTableInstance
Section titled “DataTableInstance”The table instance. Alias for TanStack Table’s Table, bound to DataTable’s features.
type DataTableInstance<TData> = Table<DataTableFeatures, TData>Query State Types
Section titled “Query State Types”QueryKeys
Section titled “QueryKeys”Names of the URL query keys.
interface QueryKeys { page?: string perPage?: string sort?: string filters?: string joinOperator?: string}Type Helpers
Section titled “Type Helpers”ValueOf
Section titled “ValueOf”Gets the literal values of a constant object.
type ValueOf<T> = T[keyof T]JoinOperatorValues
Section titled “JoinOperatorValues”The values of the JOIN_OPERATORS constant.
type JoinOperatorValues = typeof JOIN_OPERATORSFilterOperatorValues
Section titled “FilterOperatorValues”The values of the FILTER_OPERATORS constant.
type FilterOperatorValues = typeof FILTER_OPERATORSFilterVariantValues
Section titled “FilterVariantValues”The values of the FILTER_VARIANTS constant.
type FilterVariantValues = typeof FILTER_VARIANTSTanStack Table Module Augmentation
Section titled “TanStack Table Module Augmentation”This module adds custom metadata to TanStack Table’s types:
- ColumnMeta: adds label, placeholder, variant, options,
flex(layout fill), and other filter metadata - TableMeta: adds joinOperator and hasIndividualJoinOperators (filter logic), and
disableFlexFill(layout)
TypeScript can then check and autocomplete column and table metadata.