docs: add source-backed Recompose TypeScript examples#317
docs: add source-backed Recompose TypeScript examples#317landeqiming666 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
| type ToggleUpdaters = { | ||
| toggle: () => ToggleState; | ||
| close: () => ToggleState; | ||
| }; |
There was a problem hiding this comment.
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.
| type ToggleUpdaters = { | |
| toggle: () => ToggleState; | |
| close: () => ToggleState; | |
| }; | |
| type ToggleUpdaters = { | |
| toggle: () => void; | |
| close: () => void; | |
| }; |
Summary
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
IssueHunt Summary
Referenced issues
This pull request has been submitted to: