From 3eb37bdb08cfd16d7d6a7c8a75eb3cf3af38e6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Thu, 18 Jul 2024 09:26:54 +0200 Subject: [PATCH] fix: allow TValue to be specified in display and group column helpers Normally, this is not an issue, since ColumnDef is contravariant with respect to TValue. However, the user might extend BaseColumnDef or another constituent of ColumnDef such that ColumnDef becomes invariant with respect to TValue. In that case, DisplayColumnDef is no longer assignable to ColumnDef. By adding TValue as a generic argument to display and group helpers, Typescript can infer the required type of TValue. --- packages/table-core/src/columnHelper.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/table-core/src/columnHelper.ts b/packages/table-core/src/columnHelper.ts index 975a5e5b05..25e818a23e 100644 --- a/packages/table-core/src/columnHelper.ts +++ b/packages/table-core/src/columnHelper.ts @@ -66,8 +66,12 @@ export type ColumnHelper = { ) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef - display: (column: DisplayColumnDef) => DisplayColumnDef - group: (column: GroupColumnDef) => GroupColumnDef + display: ( + column: DisplayColumnDef + ) => DisplayColumnDef + group: ( + column: GroupColumnDef + ) => GroupColumnDef } export function createColumnHelper<