Skip to content

fix(tanstack-table): build atom options only when a comparator exists - #953

Merged
trueadm merged 1 commit into
mainfrom
fix/tanstack-table-atom-options
Sep 5, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/tanstack-table-atom-options

Conversation

@WebEferen

@WebEferen WebEferen commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

@octanejs/tanstack-table publishes src/, so the consumer's tsc compiles it with the consumer's flags. Under exactOptionalPropertyTypes the package does not build:

packages/tanstack-table/src/reactivity.ts(34,11): error TS2769: No overload matches this call.
packages/tanstack-table/src/reactivity.ts(38,3): error TS2322: Type '<T>(value: T, options?: TableAtomOptions<T>) => ReadonlyAtom<T>' is not
  assignable to type '<T>(initialValue: T, options?: TableAtomOptions<T> | undefined) => Atom<T>'.
  Property 'set' is missing in type 'ReadonlyAtom<T>' but required in type 'Atom<T>'.
packages/tanstack-table/src/reactivity.ts(39,11): error TS2769: No overload matches this call.

The bindings forwarded { compare: options?.compare } for every atom, including the ones table-core creates without a comparator. AtomOptions.compare is optional without undefined, so that object is not an AtomOptions under the flag. The second error is the interesting one: the options mismatch knocks out createAtom's writable overload, so createWritableAtom gets reported as returning a ReadonlyAtom and stops satisfying TableReactivityBindings.

The options object is now built only when there is a comparator to put in it. createAtom reads options?.compare ?? Object.is, so an omitted object and one holding undefined produce the same atom, and debugName was already being dropped before this change.

Found while building an Octane app with exactOptionalPropertyTypes on. It was shipping a pnpm patch against the published tarball; this is the same fix upstream.

Validation

Repo-wide pnpm typecheck and pnpm test were not run.

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • targeted: tsrx-tsc -p packages/tanstack-table/tsconfig.json, tsrx-tsc -p scripts/consumer-tsconfigs/tanstack-table.json, vitest run --project "*tanstack-table*" (9 files, 44 tests)
  • reproduction: scripts/consumer-tsconfigs/tanstack-table.json plus exactOptionalPropertyTypes and noUncheckedIndexedAccess reports the errors above before the change and nothing from this package after it

Risk / follow-ups

No gate covers this. scripts/consumer-tsconfigs/base.json mirrors what octane init scaffolds, which leaves both flags off, and turning them on in a package tsconfig pulls packages/octane/src into the program, where the same classes of error exist in bulk. A real consumer never sees those, because octane publishes dist with declarations behind skipLibCheck, while every @octanejs/* binding publishes source. The header of scripts/generate-consumer-tsconfigs.mjs already records that debt against #721; widening those projects is worth doing once core is clean.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Narrow typing fix in atom option forwarding; runtime atom behavior is unchanged when no comparator is supplied.

Overview
Fixes a TypeScript build failure for apps that compile @octanejs/tanstack-table from published src/ with exactOptionalPropertyTypes.

The reactivity bindings no longer pass { compare: options?.compare } into createAtom on every call. A new atomOptions helper only builds an AtomOptions object when table-core actually provides a comparator; otherwise createAtom is called with no options (same runtime behavior via its default compare). That restores correct overload resolution so createWritableAtom types as a writable atom again and satisfies TableReactivityBindings.

Patch changeset for @octanejs/tanstack-table.

Reviewed by Cursor Bugbot for commit 3249d5e. Bugbot is set up for automated code reviews on this repo. Configure here.

The reactivity bindings passed `{ compare: options?.compare }` into
`createAtom` for every atom, including those table-core creates without a
comparator. `AtomOptions.compare` is optional without `undefined`, so under
`exactOptionalPropertyTypes` that object is not an `AtomOptions`, the second
`createAtom` overload drops out, and `createWritableAtom` is then reported as
returning a `ReadonlyAtom` that cannot satisfy `TableReactivityBindings`.

The package publishes `src/`, so that flag belongs to the consumer. The options
object is now built only when there is a comparator to put in it; `createAtom`
reads `options?.compare ?? Object.is`, so the atoms are unchanged.
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 4, 2026
@WebEferen
WebEferen marked this pull request as ready for review September 4, 2026 16:26
@WebEferen
WebEferen marked this pull request as draft September 4, 2026 16:33
@trueadm
trueadm marked this pull request as ready for review September 5, 2026 17:26
@trueadm
trueadm merged commit d3020df into main Sep 5, 2026
86 of 95 checks passed
@trueadm
trueadm deleted the fix/tanstack-table-atom-options branch September 5, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants