Repository navigation
fix(tanstack-store): accept an explicit undefined comparator - #952
Merged
Merged
Conversation
`useStore` normalises its variadic arguments into `{ compare }`, so the key is
always present and may hold `undefined`. `UseSelectorOptions.compare` was
declared without `undefined`, which is a type error under
`exactOptionalPropertyTypes`. The package publishes `src/`, so that is the
consumer's compiler flag, not ours: an application with the flag on could not
build the package at all, and could not forward its own optional comparator
either.
Runtime behavior is unchanged; `useSelector` already read the option as
`options?.compare ?? defaultCompare`.
WebEferen
marked this pull request as ready for review
September 4, 2026 16:27
WebEferen
marked this pull request as draft
September 4, 2026 16:33
trueadm
marked this pull request as ready for review
September 5, 2026 17:26
14 of 21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@octanejs/tanstack-storepublishessrc/, so the consumer'stsccompiles it with the consumer's flags. UnderexactOptionalPropertyTypesthe package does not build at all:useStorenormalises its variadic arguments and always passes thecomparekey, which may holdundefined.UseSelectorOptions.comparewas declared withoutundefined, so the internal bridge fails, and so does any consumer forwarding their own optional comparator ({ compare: maybeCompare }).Declaring
compare?: Compare | undefinedaccepts both. No runtime change:useSelectoralready read the option asoptions?.compare ?? defaultCompare, so an absent key and an explicitundefinedbehaved identically before and after.Found while building an Octane app with
exactOptionalPropertyTypeson. It was shipping apnpm patchagainst the published tarball; this is the same fix upstream.Validation
Repo-wide
pnpm typecheckandpnpm testwere not run (unchanged elsewhere; the diff is one type declaration).pnpm format:checkpnpm typecheckpnpm testtsrx-tsc -p packages/tanstack-store/tsconfig.json,tsrx-tsc -p packages/tanstack-store/typetests/tsconfig.json,vitest run --project "*tanstack-store*"(9 files, 51 tests)scripts/consumer-tsconfigs/tanstack-store.jsonplusexactOptionalPropertyTypesandnoUncheckedIndexedAccessreports the error above before the change and nothing from this package after itRisk / follow-ups
No gate covers this.
scripts/consumer-tsconfigs/base.jsonmirrors whatoctane initscaffolds, which leaves both flags off, and turning them on in a package tsconfig pullspackages/octane/srcinto the program, where the same classes of error exist in bulk. A real consumer never sees those, becauseoctanepublishesdistwith declarations behindskipLibCheck, while every@octanejs/*binding publishes source. The header ofscripts/generate-consumer-tsconfigs.mjsalready records that debt against #721; widening those projects is worth doing once core is clean.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Type-only widening for optional properties; no runtime or behavioral change.
Overview
Fixes TypeScript compile failures when consumers build
@octanejs/tanstack-storewithexactOptionalPropertyTypes. Because the package ships source, the app’s compiler type-checksuseStore→useSelectorand any forwarded{ compare: maybeCompare }objects.UseSelectorOptions.compareis now typed as an optional property that also allowsundefined(compare?: Compare | undefined), with a short comment explaining why.useStorecan keep passing{ compare }when the third argument is omitted, and callers can forward optional comparators without assignment errors.Runtime behavior is unchanged —
useSelectorstill resolves the comparator viaoptions?.compare ?? defaultCompare.Reviewed by Cursor Bugbot for commit 6429425. Bugbot is set up for automated code reviews on this repo. Configure here.