Skip to content

docs: add source-backed Recompose TypeScript examples#317

Open
landeqiming666 wants to merge 1 commit into
piotrwitek:masterfrom
landeqiming666:docs-recompose-examples
Open

docs: add source-backed Recompose TypeScript examples#317
landeqiming666 wants to merge 1 commit into
piotrwitek:masterfrom
landeqiming666:docs-recompose-examples

Conversation

@landeqiming666

@landeqiming666 landeqiming666 commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • add a source-backed legacy Recompose section to the HOC guide
  • add typed examples for compose, withState, withHandlers, withProps, and withStateHandlers
  • keep the examples type-checked through playground sources without adding the legacy runtime package to the app bundle

Context

Related to #46.

Existing PRs cover useful parts of the request. This version keeps the source-backed README generation path and fixes the setter typing issue noted on #277.

Validation

  • npm run ci-check
  • cd playground && npm run tsc
  • cd playground && npm run lint
  • cd playground && CI=true npm run test -- --watchAll=false
  • cd playground && npm run build
  • git diff --check

IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds legacy Recompose examples to the playground and documents them in the README, allowing developers to reference HOC-based patterns for older codebases. It introduces a counter and a toggle component utilizing Recompose's state and handler utilities, along with adding @types/recompose to the dependencies. The review feedback correctly identifies a type mismatch in the ToggleUpdaters type definition, where the handlers are typed as returning ToggleState instead of void, which misrepresents the runtime behavior of withStateHandlers.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +98 to +101
type ToggleUpdaters = {
toggle: () => ToggleState;
close: () => ToggleState;
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

In recompose, the state updaters returned by withStateHandlers do not return the new state to the caller at runtime; they trigger an internal setState and return void (or undefined).

Typing them as returning ToggleState creates a type mismatch (a "type lie") where the compiler believes a value is returned, but at runtime it will be undefined.

To ensure type safety and accurately reflect runtime behavior, these handlers should be typed as returning void.

Suggested change
type ToggleUpdaters = {
toggle: () => ToggleState;
close: () => ToggleState;
};
type ToggleUpdaters = {
toggle: () => void;
close: () => void;
};

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.

1 participant