You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been working with the ListItem component in your KonstaUI library, and I've come across a type conflict that I believe may be a bug.
According to your documentation, the title prop for the ListItem component can take a string | number | React.ReactNode. However, when I pass a ReactNode to the title prop, I get the following TypeScript error:
Type 'Element' is not assignable to type 'string'.ts(2322)
index.d.ts(1943, 9): The expected type comes from property 'title' which is declared here on type 'IntrinsicAttributes & ListItemProps'
I noticed that ListItemProps extends React.HTMLAttributes, and that the title property in React.HTMLAttributes refers to the global HTML attribute title, which is of type string.
It seems that there is a conflict between the title prop defined in Props (which can be string | number | React.ReactNode), and the title prop inherited from React.HTMLAttributes (which should be a string).
As a workaround, I considered using Omit to create a type that excludes the title property from React.HTMLAttributes, and then add a title property with the correct type to Props:
However, this feels more like a temporary fix than a proper solution. I think it would be best if the library could be refactored to avoid the name collision.
I hope this helps and look forward to hearing your thoughts.
Expected Behavior
Title should accept string | number | ReactNode, not just string.
The ListItem type definition is as follows:
/**
* Content of the list item "title" area
*/
title?: string | number | React.ReactNode;
Actual Behavior
Any value that's not a string causes a type error for the title field. (This doesn't apply to the subtitle field, which has the same type within ListItem type definition, leading me to believe it's a type conflict with HTMLElement.
Check that this is really a bug
Reproduction link
https://stackblitz.com/edit/konsta-react-euvdy9?file=App.tsx
Bug description
Hello,
I've been working with the ListItem component in your KonstaUI library, and I've come across a type conflict that I believe may be a bug.
According to your documentation, the title prop for the ListItem component can take a string | number | React.ReactNode. However, when I pass a ReactNode to the title prop, I get the following TypeScript error:
I noticed that ListItemProps extends React.HTMLAttributes, and that the title property in React.HTMLAttributes refers to the global HTML attribute title, which is of type string.
Here's the relevant part of the type definition:
It seems that there is a conflict between the title prop defined in Props (which can be string | number | React.ReactNode), and the title prop inherited from React.HTMLAttributes (which should be a string).
As a workaround, I considered using Omit to create a type that excludes the title property from React.HTMLAttributes, and then add a title property with the correct type to Props:
However, this feels more like a temporary fix than a proper solution. I think it would be best if the library could be refactored to avoid the name collision.
I hope this helps and look forward to hearing your thoughts.
Expected Behavior
Title should accept string | number | ReactNode, not just string.
The ListItem type definition is as follows:
Actual Behavior
Any value that's not a string causes a type error for the title field. (This doesn't apply to the subtitle field, which has the same type within ListItem type definition, leading me to believe it's a type conflict with HTMLElement.
Konsta UI version
2.0.0
Platform/Target and Browser Versions
macOS
Validations
Would you like to open a PR for this bug?
The text was updated successfully, but these errors were encountered: