Skip to content

Improve TS exports and types#20

Merged
captbaritone merged 5 commits into
thejustinwalsh:mainfrom
markerikson:feature/ts-exports
Jan 15, 2026
Merged

Improve TS exports and types#20
captbaritone merged 5 commits into
thejustinwalsh:mainfrom
markerikson:feature/ts-exports

Conversation

@markerikson

Copy link
Copy Markdown
Contributor

This PR:

  • Fixes a set of TS type errors I saw when using the published react-concurrent-store@0.01 build in React-Redux
    • Exported ISource
    • Added ReactStore interface
    • Made Store fields not private to fix TS4094 error
  • Deduplicates the Store<S, any> types in StoreManager.ts and ignores the lint warning for use of any
  • Uses never in a couple places in useStoreSelector, which seems to help with the follow-up PR to pass through prevResult
  • Replaces the use of === comparisons in useStoreSelector with the common is() util to properly handle NaN values

Background

When I tried to use the 0.0.1 build in React-Redux, I got these errors when I built React-Redux:

src/utils/reactStoreEnhancer.ts(5,9): error TS4023: Exported variable 'createStoreFromSource' has or is using name 'ISource' from external module "react-redux/node_modules/react-concurrent-store/dist/index" but cannot be named.
src/utils/reactStoreEnhancer.ts(5,9): error TS4094: Property 'committedState' of exported anonymous class type may not be private or protected.
src/utils/reactStoreEnhancer.ts(5,9): error TS4094: Property 'source' of exported anonymous class type may not be private or protected.
src/utils/reactStoreEnhancer.ts(5,9): error TS4094: Property 'state' of exported anonymous class type may not be private or protected.

Seems TS doesn't like an "anonymous class type" that also has private fields.

I initially tried marking them as public in a local build, and that resolved the errors for me.

Here, I've both defined a ReactStore interface that Store implements, and also removed private (which I guess is about the same as marking them as public?)

I also cleaned up some of the type usage as I worked through the later PR changes, and combined those here.

Unrelated to the type changes, I saw that some of my later tests happened to use NaN as a selected value, and that led to infinite render loops. Replacing the === comparison with is() fixed that.

} else {
return x !== x && y !== y;
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just use Object.is? I think that's what React claims to use. If this is expected to provide that same behavior maybe we need to add a comment explaining why this particular behavior?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets revisit this as a followup. I think the rest of the pr is fine so I'm going to merge.

@pkg-pr-new

pkg-pr-new Bot commented Jan 15, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/thejustinwalsh/react-concurrent-store@20

commit: 86f3ccc

@captbaritone captbaritone merged commit 2842481 into thejustinwalsh:main Jan 15, 2026
3 checks passed
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