Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Improve return type of useNodesData#5703

Open
peterkogo wants to merge 1 commit intomainfrom
fix/use-nodes-data-type
Open

Improve return type of useNodesData#5703
peterkogo wants to merge 1 commit intomainfrom
fix/use-nodes-data-type

Conversation

@peterkogo
Copy link
Member

closes #5657

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: ce6c869

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@xyflow/react Patch
@xyflow/svelte Patch
@xyflow/system Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Walkthrough

This change improves the return type of the useNodesData hook across React and Svelte packages by introducing a new DistributivePick utility type. A patch changeset documents updates for @xyflow/react, @xyflow/svelte, and @xyflow/system. The new DistributivePick type distributes over unions when picking properties, enabling better type narrowing by node type. The useNodesData hook return type was updated from Pick<NodeType, 'id' | 'type' | 'data'> to DistributivePick<NodeType, 'id' | 'type' | 'data'> in both implementations. Example components in React and Svelte were refactored to use the improved typing and updated logic patterns.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Improve return type of useNodesData' is concise and clearly describes the main change - enhancing the return type of the useNodesData hook for better type narrowing.
Description check ✅ Passed The description 'closes #5657' is related to the changeset as it references the linked issue that the PR addresses regarding the useNodesData return type improvement.
Linked Issues check ✅ Passed The PR successfully implements the DistributivePick utility type and applies it to useNodesData hooks in React and Svelte packages, enabling proper type narrowing through discriminated unions as required by issue #5657.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the PR objective: implementing DistributivePick type utility, updating hook return types, and demonstrating the fix with updated examples; no extraneous changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
examples/react/src/examples/UseNodesData/UppercaseNode.tsx (1)

3-3: Remove unused isTextNode import.

The isTextNode helper imported on line 3 is no longer used after the component was refactored to check nodesData?.type === 'text' directly.

Proposed cleanup
-import { isTextNode, type TextNode, type MyNode, type UppercaseNode } from '.';
+import { type TextNode, type MyNode, type UppercaseNode } from '.';

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

useNodesData type not narrowed down properly

1 participant