Skip to content

Check each column's Cell and options, and keep the cell args of declared lists - #203

Merged
NullVoxPopuli merged 1 commit into
universal-ember:mainfrom
NullVoxPopuli-ai-agent:nvp/cell-args-follow-up
Sep 23, 2026
Merged

NullVoxPopuli merged 1 commit into
universal-ember:mainfrom
NullVoxPopuli-ai-agent:nvp/cell-args-follow-up

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown

Follow-up to #202, for the problems johanrd raised there: johanrd#5, johanrd#6, and the options gap. Nothing new needs a type argument. A declared type still replaces the inferred one.

headlessTable(this, {
  columns: () => [
    { key: 'age', Cell: UnitCell, options: () => ({ unit: 'years' }) }, // ok
    { key: 'height', Cell: UnitCell },         // error: the Cell asks for @options
    { key: 'weight', Cell: UnitCell, options: () => ({ unit: 3 }) }, // error: unit is not a number
  ],
  data: () => this.people,
  meta: { currency: 'EUR' },
});

Changes

  • Declared lists keep their cell args (Keep the cell args a declared column list states johanrd/table#6). A shared component that takes ColumnConfig<Row, unknown, unknown, CellArgs>[] from its caller can build the table. The args come from a type-only [cellArgsType] property, as in Keep the cell args a declared column list states johanrd/table#6. It is read only when the elements have that property. Object literals do not have it, so a list written in place still reads its Cells.
  • Each column is checked against its own Cell. The Cell must take the row type, the column's meta, and the table meta. When the Cell asks for @options, the column's options must return them. Infer the types of column meta and table meta #202 listed that as a limit.
  • Fix: a table meta with a callback that has parameters lost the inference. On main, a table with a meta, a Cell with args, and for example options: ({ row }) => ... lost its cell args and column meta. The Cell was then rejected. The cause is in instantiateContextualType: once any type parameter has a candidate (here Meta, from meta), contextual signatures are instantiated with the inferences made so far, and the Cell check read the column list before it had any. The check now runs per column, through the numeric keys of the inferred list.
  • Exports (Export CellOptions and CellOptionsOf johanrd/table#5): CellOptions and CellOptionsOf.
  • Docs: the "Typing meta and cells" page covers the options check and shared table components.

Tests

  • declared-cell-args.test.ts: the generic wrapper from Keep the cell args a declared column list states johanrd/table#6, a declared list whose Cells ask for none of its args, and a list written in place.
  • options-check.test.ts: options against the Cell's @options: wrong type, missing, and on another column. Also the exported types, and the case that failed on main.
  • cell-args.test.ts: a table meta plus a callback keeps the cell args and the column meta.

Checked:

  • The table type tests pass with TS 5.6, 6.0, and the TS 7 nightly.
  • test-app type-checks with TS 5.6, 6.0, and the TS 7 nightly.
  • pnpm lint: pass.
  • test-app tests: 189 of 189 pass.
  • nollm --diff origin/main: no problems.

🤖 Generated with Claude Code

…red lists

- A column list with a declared type keeps its cell args, like it keeps
  its column meta. A shared component that takes
  `ColumnConfig<Row, unknown, unknown, CellArgs>[]` from its caller can
  build the table (johanrd#6).
- Each column written in place is checked on its own: its Cell takes the
  row type, the column's meta and the table meta, and when the Cell asks
  for `@options`, the column's `options` returns them.
- A table `meta` together with a callback that has parameters no longer
  loses the inferred cell args and column meta. The Cell check read the
  column list while TypeScript was still inferring it.
- `CellOptions` and `CellOptionsOf` are exported (johanrd#5).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@NullVoxPopuli NullVoxPopuli added the enhancement New feature or request label Sep 23, 2026
@NullVoxPopuli
NullVoxPopuli merged commit 1df1dc6 into universal-ember:main Sep 23, 2026
15 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 23, 2026
NullVoxPopuli pushed a commit that referenced this pull request Sep 23, 2026
#204 made Cell a CellComponent. Inferring from ComponentLike gives any,
so the three checks from #203 fail on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants