Skip to content

Add column meta and typed Cell options - #2

Open
johanrd wants to merge 1 commit into
mainfrom
column-meta
Open

johanrd wants to merge 1 commit into
mainfrom
column-meta

Conversation

@johanrd

@johanrd johanrd commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Replaces the approach in universal-ember#111. Table, Column and the plugins keep their type parameters, so T is still inferred and no plugin file changes.

  • meta: static facts about a column (alignment, export width, a header component). Apps declare the keys once on ColumnMeta<T>, then read column.meta with no row. Same idea as columnDef.meta in TanStack Table.
  • column<T>(): checks one column's Cell against that column's options. A wrong or missing option is a compile error. Same idea as flexRenderComponent(component, options).
  • CellContext, CellOptions, CellArgs and TypedColumnConfig are public, so apps stop importing from -private.
const col = column<Person>();

headlessTable(this, {
  columns: () => [
    { key: 'name', meta: { align: 'left' } },
    col({ key: 'age', Cell: UnitCell, options: () => ({ unit: 'years' }) }),
  ],
  data: () => people,
});

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It changes the published library's public type surface with subtle TypeScript generics currying and interface declaration-merging semantics that warrant final human sign-off, even though no concrete defects were found.

Review effort: Balanced
Findings: None

What changed in this PR

This PR extends the public API of @universal-ember/table with two type-focused features: a per-column meta bag for static, row-independent facts (alignment, export width, header component, etc.), and a curried column<T>() helper that type-checks a column's Cell component against that column's own options. It also promotes CellContext, CellOptions, CellArgs, and TypedColumnConfig to the public entrypoint so consumers no longer need to import from -private. The changes preserve existing type inference (T is still inferred from data/columns) and require no plugin changes.

Changes:

  • Add an app-augmentable ColumnMeta<T> interface plus a meta? field on ColumnConfig<T> and a meta getter on Column.
  • Add column<T>() helper with CellArgs and TypedColumnConfig to enforce Cell/options agreement per column; widen Cell args to allow an optional @options.
  • Expose the new/existing types (column, CellArgs, TypedColumnConfig, CellContext, CellOptions, ColumnMeta) from the public index and add type tests.
File Description
table/​src/​index.ts Exports the new column helper and the newly public types.
table/​src/​-private/​interfaces/​column.ts Adds ColumnMeta<T>, a meta? config field, and widens Cell args with optional options.
table/​src/​-private/​column.ts Adds a meta getter delegating to config.meta.
table/​src/​-private/​column-helper.ts New file defining CellArgs, TypedColumnConfig, and the curried column<T>() helper.
table/​src/​-private/​-type-tests/​column-options.test.ts Type tests covering typed options, meta declaration merging, and inference.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants