Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: allow TValue to be specified in display and group column helpers #5667

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mithodin
Copy link

By default, the return types of columnHelper.display and columnHelper.group are fine, because ColumnDef<TData, TValue> is contravariant with respect to TValue. However, the user might extend ColumnDefBase (or another type constituent of ColumnDef) via declaration merging, such that this no longer holds. At that point, the helper can no longer be used because its return type is no longer assignable to ColumnDef. Adding the type argument to display and group fixes this issue.

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<TData, unknown> is no longer assignable to ColumnDef<TData, TValue>. By adding TValue as a generic argument to display and group helpers, Typescript can infer the required type of TValue.
Copy link

nx-cloud bot commented Aug 3, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3eb37bd. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

Copy link

pkg-pr-new bot commented Aug 3, 2024

commit: 3eb37bd

pnpm add https://pkg.pr.new/@tanstack/angular-table@5667
pnpm add https://pkg.pr.new/@tanstack/lit-table@5667
pnpm add https://pkg.pr.new/@tanstack/match-sorter-utils@5667
pnpm add https://pkg.pr.new/@tanstack/qwik-table@5667
pnpm add https://pkg.pr.new/@tanstack/react-table@5667
pnpm add https://pkg.pr.new/@tanstack/react-table-devtools@5667
pnpm add https://pkg.pr.new/@tanstack/solid-table@5667
pnpm add https://pkg.pr.new/@tanstack/svelte-table@5667
pnpm add https://pkg.pr.new/@tanstack/table-core@5667
pnpm add https://pkg.pr.new/@tanstack/vue-table@5667

Open in Stackblitz

More templates

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