-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(typings): unable to set many typical html element props #1072
Comments
I would assume the latter would be more useful to users. That said, I'd like to get some feedback on this from our ts users before merging a fix. /cc @tomitrescak @hlehmann @jasonritchie @garyham @asvetliakov @halfmatthalfcat @psudarsa You all have been active in our ts decisions in the past, let us know your thoughts here. |
For now you can use module augmentation i think declare module "semantic-ui-react" {
interface SegmentProps {
id?: string;
}
// or
interface SegmentProps extends React.HTMLProps<HTMLElement> {}
} Personally i'm doing 1) approach for elements where passing html attributes does make sense (input, form, etc...) The 2) approach destroys parameter validation since you can pass anything. |
Good point, this seems rather unfavorable. |
The validation still works as expected for the explicitly specified properties. |
Yes, seems i was wrong about 2. Latest compiler version works as expected. |
If there is an agreement on 2, I'd merge a PR for that. It would be nice not to have the common HTML props flooding the completions. I think the intent is for users to see the custom component props. |
For clarity, we're ready for a community PR here implementing this pattern for all components: interface SegmentProps {
...
[key: string]: any;
} |
@levithomason I'm interested in completing this, can my PR contains all the component listed in the TODO above? Thanks |
@dstpierre awesome! I'd prefer we do only a few at a time. It is easier to review and manage conflicts that way. Also, anytime there is a list of items todo like this, there always seems to be other small bug fixes and updates that are necessary along the way. Keeping the PRs small keeps the changes manageable, whereas, grouping them tends to lead to a massive PR that has a very hard time getting merged. |
@dstpierre looks like you're in a mad race with @layershifter for this one! 😉 |
It's done 😄 |
🎉 all praise be to you @layershifter, completely amazing work! |
I was running in to problems trying to set the
id
attribute forSegment
. Currently the typings don't allow this in TSX, even if it would be perfectly ok in JSX. The same is true for a number of other standard html attributes and Semantic-UI-React-Components.One option would be to change
to
giving the ability to set a huge amount of additional attributes, including
id
. This however floods the intellisense with attributes that are probably unneeded 95% of the time.Another option would be to add an index type:
which would then allow any property to be set without flooding intellisense.
Any thoughts?
The text was updated successfully, but these errors were encountered: