-
Notifications
You must be signed in to change notification settings - Fork 297
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(@toss/emotion-utils): SpacingProps: Replace never
with Omit
for children
#425
Conversation
👷 Deploy request for slash-libraries pending review.Visit the deploys page to approve it
|
never
with Omit
for children
I want to know what effect this PR has 😊 |
@okinawaa I should have added an explanation when I submitted the PR. I apologize. There are various reasons, but the most compelling one is that unnecessary automatic completion of "children" in props can create confusion for developers. Instead, by completely eliminating Children using Omit, autocomplete would be removed, potentially eliminating confusion for developers. |
I saw this pull request and was intrigued, so here's a small comment...! 🙏 type SpacingProps = Omit<React.HTMLProps<HTMLDivElement>, "size" | "children" | "direction"> & {
children?: undefined;
direction?: AxisDirection | undefined;
size: CSSPixelValue;
} The <Spacing direction="horizontal" size={40} /> Given the use case of |
I'm curious about why the type is explicitly set to 'undefined' for 'children' when it's not necessary. I think this change actually lowers the DX by providing unnecessary autocompletion to developers. and I'm also curious why size and direction are being excluded using Omit instead of ExtendHTMLProps. I think I might be wrong understandIf I gave me wrong understanding understandingstanding, please tell me when I got wrong understand Lastly, thank you for always provoking my curiosity! Your comments are a great help to my learning!! |
@SEOKKAMONI 👋 type SpacingProps = ExtendHTMLProps<
HTMLDivElement,
{
children?: never;
direction?: AxisDirection;
size: CSSPixelValue;
}
>; The type of the existing type SpacingProps = Omit<React.HTMLProps<HTMLDivElement>, "size" | "children" | "direction"> & {
children?: undefined;
direction?: AxisDirection | undefined;
size: CSSPixelValue;
} You can understand this by looking at the code where export type ExtendHTMLProps<Elem extends HTMLElement, T> = Omit<HTMLProps<Elem>, keyof T> & T; The key point is that I also agree with your opinion!! 🤗 |
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.
Thanks! Seems that we have to exclude children
from the props of Spacing
.
Overview
SpacingProps: Replace
never
withOmit
for childrenPR Checklist