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

Skip to content

Conversation

@keepmhwn
Copy link

@keepmhwn keepmhwn commented Dec 4, 2025

Summary

Improves type safety for the pathOptions prop in EdgeProps by replacing the any type with a new InferPathOptions utility type that properly infers the path options from the edge type.

Changes

  • Added InferPathOptions<E> utility type that extracts the pathOptions type from an edge
  • Updated EdgeProps.pathOptions to use InferPathOptions<EdgeType> instead of any
  • Removed the TODO comment about improving types for pathOptions

Example

With the updated typing, custom edges automatically provide strongly typed pathOptions.
For example:

type CustomEdgeType = Edge<CustomEdgeData> & {
  pathOptions?: {
    color: string;
  };
};

When using EdgeProps, the pathOptions property is now inferred as:

pathOptions?: { color: string };

This ensures that consumers get accurate autocomplete and type checking for their custom edge options.

Summary by CodeRabbit

  • Chores
    • Enhanced TypeScript type definitions for edge configurations, enabling improved IDE autocompletion and stricter compile-time type checking for path options.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

⚠️ No Changeset found

Latest commit: 780b628

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

A new utility type InferPathOptions<E> was introduced to extract the pathOptions type from Edge subtypes using conditional typing. The EdgeProps<EdgeType> interface was updated to apply this utility type to its pathOptions property, replacing the previous any type annotation. This change affects the type inference for edge path options throughout the React package's type definitions.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing the loose 'any' type for EdgeProps.pathOptions with a strict, inferred type for better type safety.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ede221a and 780b628.

📒 Files selected for processing (1)
  • packages/react/src/types/edges.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/react/src/types/edges.ts (2)
packages/svelte/src/lib/index.ts (1)
  • Edge (40-40)
packages/svelte/src/lib/types/edges.ts (1)
  • Edge (16-24)
🔇 Additional comments (2)
packages/react/src/types/edges.ts (2)

64-65: Utility type for inferring pathOptions looks correct

The conditional + infer utility cleanly extracts the pathOptions member from edge subtypes while retaining an any fallback for edges that don't define it, so this tightens typing without breaking existing consumers.


119-119: EdgeProps.pathOptions now correctly tracks the edge’s own path options

Hooking pathOptions up to InferPathOptions<EdgeType> ensures that custom edges with a typed pathOptions field get precise autocomplete and type checking through EdgeProps, which aligns well with the PR’s goal and remains backward compatible for untyped edges.


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.

1 participant