Skip to content

TypeScript Types

TypeScript type definitions and interfaces for the data table.

The types/ directory contains all TypeScript type definitions and interfaces used throughout the data table components.

Option type for select/multi-select filters.

interface Option {
label: string
value: string
count?: number
icon?: React.ComponentType<{ className?: string }>
}

Filter variant type defining the UI control type.

type FilterVariant =
| "text"
| "number"
| "range"
| "date"
| "dateRange"
| "select"
| "multiSelect"
| "boolean"

Filter operator type defining the comparison logic.

type FilterOperator =
| "ilike"
| "not.ilike"
| "eq"
| "neq"
| "in"
| "not.in"
| "empty"
| "not.empty"
| "lt"
| "lte"
| "gt"
| "gte"
| "between"
| "relative"

Join operator type for combining multiple filters.

type JoinOperator = "and" | "or" | "mixed"

Extended column filter with additional 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
}

Extended column sort for URL state management.

interface ExtendedColumnSort<TData> {
id: Extract<keyof TData, string>
desc: boolean
}

Global filter type.

type GlobalFilter = string | Record<string, unknown>

Extended column definition for data table. Inherits all TanStack Table ColumnDef properties.

type DataTableColumnDef<TData, TValue = unknown> = ColumnDef<TData, TValue>

Extended column metadata interface (augments 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
}

Extended table metadata interface (augments 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, so set it statically rather than toggling it at runtime.

Data table row type. Alias for TanStack Table Row.

type DataTableRow<TData> = Row<TData>

Data table instance type. Alias for TanStack Table.

type DataTableInstance<TData> = Table<TData>

Query keys for URL state management.

interface QueryKeys {
page?: string
perPage?: string
sort?: string
filters?: string
joinOperator?: string
}

Utility type to get the literal values from constant objects.

type ValueOf<T> = T[keyof T]

Convenience type for accessing JOIN_OPERATORS constant values.

type JoinOperatorValues = typeof JOIN_OPERATORS

Convenience type for accessing FILTER_OPERATORS constant values.

type FilterOperatorValues = typeof FILTER_OPERATORS

Convenience type for accessing FILTER_VARIANTS constant values.

type FilterVariantValues = typeof FILTER_VARIANTS

The types module augments TanStack Table’s type definitions to add custom metadata:

  • ColumnMeta - Adds label, placeholder, variant, options, flex (layout fill), and other filter-related metadata
  • TableMeta - Adds joinOperator, hasIndividualJoinOperators for filter logic, and disableFlexFill for layout

This allows TypeScript to provide proper type checking and autocomplete for column and table metadata throughout the data table components.