Skip to content
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

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

SEOKKAMONI
Copy link
Contributor

@SEOKKAMONI SEOKKAMONI commented Feb 4, 2024

Overview

SpacingProps: Replace never with Omit for children

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

Copy link

netlify bot commented Feb 4, 2024

👷 Deploy request for slash-libraries pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 145d5fb

@SEOKKAMONI SEOKKAMONI changed the title refactor(@toss/emotion-utils): SpacingProps: Replace 'never' with 'Omit' for children refactor(@toss/emotion-utils): SpacingProps: Replace never with Omit for children Feb 4, 2024
@okinawaa
Copy link
Member

okinawaa commented Feb 5, 2024

I want to know what effect this PR has 😊

@SEOKKAMONI
Copy link
Contributor Author

SEOKKAMONI commented Feb 5, 2024

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.

image

@ssi02014
Copy link
Contributor

ssi02014 commented Feb 5, 2024

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 SpacingProps type has children?: undefined as shown above.

<Spacing direction="horizontal" size={40} />

Given the use case of Spacing, I think it's appropriate to exclude the children type, the same as @SEOKKAMONI

@SEOKKAMONI
Copy link
Contributor Author

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 SpacingProps type has children?: undefined as shown above.

<Spacing direction="horizontal" size={40} />

Given the use case of Spacing, I think it's appropriate to exclude the children type, the same as @SEOKKAMONI

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!!

@ssi02014
Copy link
Contributor

ssi02014 commented Feb 10, 2024

@SEOKKAMONI 👋
It seems like my intention wasn't properly conveyed! 😭

type SpacingProps = ExtendHTMLProps<
  HTMLDivElement,
  {
    children?: never;
    direction?: AxisDirection;
    size: CSSPixelValue;
  }
>;

The type of the existing SpacingProps ultimately results in the following!

type SpacingProps = Omit<React.HTMLProps<HTMLDivElement>, "size" | "children" | "direction"> & {
    children?: undefined;
    direction?: AxisDirection | undefined;
    size: CSSPixelValue;
}

스크린샷 2024-02-11 오전 3 19 09

You can understand this by looking at the code where ExtendHTMLProps is defined...!

export type ExtendHTMLProps<Elem extends HTMLElement, T> = Omit<HTMLProps<Elem>, keyof T> & T;

The key point is that I also agree with your opinion!! 🤗
But the maintainer's intent is important, and there may be history we don't know about 🙏

Copy link
Collaborator

@raon0211 raon0211 left a 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.

@raon0211 raon0211 merged commit 74b2489 into toss:main Mar 22, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants