Integration issues between @heroui/react and @tanstack/router: TypeScript errors with link components #4976
juancarlosf2
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While I've successfully implemented a custom Link component that works with proper TypeScript support, I'm experiencing issues with @heroui/react's polymorphic pattern (as prop) when used with @tanstack/router. Specifically, when trying to use Button with as={Link}, TypeScript doesn't properly recognize router-specific props like params.
Current Behavior
My custom Link component works with full TypeScript support (see implementation below)
When using Button with
as={Link}
, TypeScript doesn't properly recognize router propsNo intellisense for router-specific props like params, search, etc. in polymorphic contexts
Expected Behavior
Button with
as={Link}
should maintain full type checking for all router props, providing proper intellisense and type safety.Reproduction
I've created a minimal reproduction of this issue in this sandbox
This sandbox demonstrates the typing issues when using Button with Link as a polymorphic component.
Code Examples
My working Link implementation (with proper types):
Environment
@heroui/react version: 2.7.4
@tanstack/react-router version: 1.112.0
@tanstack/react-start version: 1.112.3
React version: 19.0.0
TypeScript version: 5.7.2
Browser: Chrome latest
OS: macOS Sonoma 14.3
Additional Information
I've successfully implemented a custom Link component that properly merges types from both TanStack Router and HeroUI, providing full intellisense for router props. However, when using HeroUI's polymorphic pattern (as prop) with Button or other components, TypeScript doesn't correctly propagate the router props to the resulting component.
The issue appears to be in how type information is handled when using the polymorphic pattern with components that have specialized prop requirements like TanStack Router's Link.
I'm looking for a solution that maintains full type safety while allowing use of HeroUI's polymorphic components with TanStack's routing capabilities.
Beta Was this translation helpful? Give feedback.
All reactions