-
Notifications
You must be signed in to change notification settings - Fork 82
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
refactor: Improve typing so it shows the props #1591
Changes from 2 commits
262164b
1848148
eca0877
7763958
3aa1b94
4d0c3dc
751e39d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import React from 'react'; | ||
|
||
export type ExpandProps<T> = T extends object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, this is quite cool. Now I need to understand how it works :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What this does is get the type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the explanation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add some explanation around this type in the code comment, like the purpose and how it works (pretty much your answer for Alex) for the future us. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 ☝️ |
||
? T extends infer O | ||
? { [K in keyof O]: O[K] } | ||
: never | ||
: T; | ||
|
||
type Overwrite<T, U> = Omit<T, keyof U> & U; | ||
|
||
type PropsWithAs<P, E extends React.ElementType> = P & { as?: E }; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ export type { | |
PolymorphicComponent, | ||
PropsWithHTMLElement, | ||
PolymorphicProps, | ||
ExpandProps, | ||
} from './Primitive'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can ExpandProps be a part of ButtonGroupProps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly no, because it would expand the Type inside the
ButtonGroupProps
, but here it would show asButtonGroupProps
only, and not the values inside it