Skip to content

Add per-table types: column meta, table meta, cell args - #3

Open
johanrd wants to merge 6 commits into
mainfrom
per-table-meta
Open

johanrd wants to merge 6 commits into
mainfrom
per-table-meta

Conversation

@johanrd

@johanrd johanrd commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Replaces #2. A table declares its types once. They apply wherever the table is read: column.meta, table.config.meta and the args of column.Cell, also inside value, options and a Cell.

interface ReportTypes {
  columnMeta: { align?: 'left' | 'right' };
  cellArgs: { dateRange: DateRange };
}

headlessTable(this, { types: tableTypes<ReportTypes>(), columns, data });
// <column.Cell @row={{row}} @column={{column}} @dateRange={{@dateRange}} />

Cowritten by Claude

- ColumnConfig.meta: static facts about a column, typed by the
  augmentable ColumnMeta<T>, read as column.meta without a row.
- column<T>(): checks one column's Cell against its own options.
- Export CellContext, CellOptions, CellArgs, TypedColumnConfig.

Table, Column and the plugins keep their type parameters.
A table declares its own types once:

  interface ReportTypes { columnMeta: ...; tableMeta: ... }
  headlessTable(this, { types: tableTypes<ReportTypes>(), ... })

column.meta and table.config.meta then have these types wherever they
are read, also inside value, options and Cell. The slot names are those
of TanStack Table.

Tables that declare nothing are typed as before. Seven test sites
annotated a bare Table and assigned a typed table to it; that never was
assignable, so they name the table's type now.
@johanrd johanrd changed the title Add per-table types for column and table meta Add per-table types: column meta, table meta, cell args Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant