Column defs of any value type (AnyValue)
AnyValue is a brand interface ('~latticeAnyValue'), exported from @ember-lattice/core.
Context
TanStack types the table columns option and the columns of a group def as
ColumnDef<TFeatures, TData, any>. Lattice has no any, so the port used
ColumnDef<TFeatures, TData, unknown>. Thus a list of defs with different value types did not
fit. An example is a ColumnDef<…, string> def and a ColumnDef<…, number> def in one list,
written without columnHelper.
The cause is a cycle in the types. ColumnDef has cell and footer, which get a
CellContext or a HeaderContext. These contexts have a Column, and Column has the
ColumnDef again. Through the built declarations, TypeScript measures TValue of Column and
HeaderContext as invariant. The result depends on the order of the checks. Thus
ColumnDef<…, string> does not fit ColumnDef<…, unknown>, also with the bivarianceHack
method syntax on ColumnDefTemplate. out TValue annotations do not help, because TypeScript
cannot prove covariance through the generic ExtractFeatureMapTypes. A test that imports src
does not show the failure. The type test packages/core/tests/types/columnValueVariance.ts
imports @ember-lattice/core, and thus the declarations.
columnHelper.columns already infers one value type for each column (ColumnDefsOf). This ADR
is about a raw list without the helper.
Decision drivers
Not recorded in the original ADR.
Options considered
Options
- A wrapper type with
(props: never) => unknown. A mapped copy ofColumnDefgives each value callback aneverinput. Each def fits, but an inlinecell: ctx => …getsctx: never(tests/unit/flex-render.test.ts). Also, TypeScript cannot inferTFeaturesandTDatathrough the mapped type from a typed list of defs (filterFns.test.ts,columnPinningFeature.utils.test.ts,rowModelSlots.test.ts). Rejected. - A mapped copy with
NoInfer. It keeps the contextual types but has no inference ofTFeaturesandTDatafrom the columns. The same three tests fail. Rejected. - A union of
ColumnDefand a mapped copy.ColumnDefgives the inference. But two copies of a callback type in the union are not identical during the inference of a genericconstructTablecall. Then the inlinerow =>andctx =>callbacks have no contextual type. This occurs also with an identity copy. Rejected. - A brand value type inside
ColumnDef. Accepted, see below.
Decision
AnyValueis a brand interface ('~latticeAnyValue'), exported from@ember-lattice/core.ValueMember<TValue, TMember, TErased>is[TValue] extends [AnyValue] ? TErased : TMember. Each def member that usesTValuegoes through it:header,footer,cell,aggregatedCell,spanColumns,spanRowsandgetAggregationValue: the type forunknown, orCallableFunction.accessorFn:AccessorFn<TData, unknown>.metaandaggregationFn: the type forunknown.
- The table
columnsoption and thecolumnsof a group def areReadonlyArray<ColumnDef<TFeatures, TData, AnyValue>>. The type stays theColumnDefalias, so TypeScript infersTFeaturesandTDatafrom its type arguments. - Each function fits
CallableFunction.CallableFunctionhas no call signature, so an inline callback keeps the contextual type of theunknownform. TableFeature.getDefaultColumnDefreturnsColumnDefBase_All<…, unknown>and has noTValueparameter. With a genericTValue,ValueMemberstays deferred, and a default callback loses its contextual type.
Casts
ValueMember stays deferred for a generic TValue. Three casts, each with a comment, close the
gap:
constructColumns(coreColumnsFeature.utils.ts) casts eachAnyValuedef toColumnDef<…, unknown>. A column reads its values asunknown, as TanStack does withany.constructColumncastsaccessorFntoAccessorFn<TData, TValue>.column_getAggregationValuecastsgetAggregationValueto itsTValuefunction type.
Consequences
Consequences and limits
- For an
AnyValuedef, a callback member accepts a function of each signature. This is as wide as TanStack'sany. [any] extends [AnyValue]is true. ThusColumnDef<…, any>(the TanStack idiom for a mixed list) givesCellContext<…, unknown>, notCellContext<…, any>. AnIsAnyguard inValueMemberchanges the measured variance ofCelland breaks generic core code (cellSelectionFeature.utils.ts), so there is no guard. Apps do not needanyfor a mixed list in Lattice.[never] extends [AnyValue]is also true, soColumnDef<…, never>gets the erased members.- An app
ColumnMetaaugmentation that usesTValuein an input position does not fit the option, becausemetauses the type forunknown. - The type of
TableOptions['columns']changed.tests/unit/readonlyOptions.test.tsasserts the new type.
Confirmation
Not recorded in the original ADR.
Interview record
Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.
| Question | Answer | Source |
|---|---|---|
| Where does the text of this page come from? | From the Markdown file docs/adr/0027-column-def-any-value.md at commit 4c77ac4. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so. | Document: docs/adr/0027-column-def-any-value.md |
Changelog
| Date | Author | Change |
|---|---|---|
| 2026-12-02 | Joe Gaudet | Status in the Markdown file: accepted, 2026-12-02. |
| 2026-12-03 | Joe Gaudet | Commit 7ce4af2: Lattice 1.0 (#1) |
| 2026-12-04 | Joe Gaudet (agent) | Converted from docs/adr/0027-column-def-any-value.md to this page. The text is the text of the Markdown file. |
The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.