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

Require at least 1 child in JSX components #2466

Merged
merged 5 commits into from
Jun 6, 2024
Merged

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Jun 6, 2024

This changes the types and validation for JSX components to require at least one child. Previously it was possible to do something like <Box children={[]} />, but this will now result in an error.

@Mrtenz Mrtenz requested a review from a team as a code owner June 6, 2024 08:58
FrederikBolding
FrederikBolding previously approved these changes Jun 6, 2024
Copy link
Member

@FrederikBolding FrederikBolding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but there are some type problems in CI it seems

Copy link

codecov bot commented Jun 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.33%. Comparing base (491f8fb) to head (51a51ff).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2466   +/-   ##
=======================================
  Coverage   94.33%   94.33%           
=======================================
  Files         438      438           
  Lines        9037     9039    +2     
  Branches     1384     1384           
=======================================
+ Hits         8525     8527    +2     
  Misses        512      512           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Mrtenz Mrtenz merged commit 0c166a9 into main Jun 6, 2024
153 checks passed
@Mrtenz Mrtenz deleted the mrtenz/non-empty-children branch June 6, 2024 09:58
Mrtenz added a commit that referenced this pull request Jun 7, 2024
In #2466 we changed the types and validation of JSX components to use
`NonEmptyArray<Type>` as children. This causes issues however when using
utility functions like `.map()` and `.filter()`, since they return a
regular `Type[]` type. This is not great for devex, since it would
require type assertions everywhere.

I've changed the types to accept `Type[]`, though we technically still
validate `NonEmptyArray<Type>`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants