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: ts checking conditionallyrender props #7840

Merged
merged 4 commits into from
Aug 30, 2024
Merged

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Aug 12, 2024

About the changes

Fix issues found by TS checking after removing ConditionallyRender
Prerequisite for #7825
See https://github.com/Unleash/unleash/actions/runs/10350980657/job/28648500408?pr=7825

Error: src/component/admin/groups/GroupsList/GroupCard/GroupCard.tsx(166,37): error TS2322: Type 'Element | null' is not assignable to type 'ReactElement<any, any>'.
  Type 'null' is not assignable to type 'ReactElement<any, any>'.
Error: src/component/common/Badge/Badge.tsx(74,9): error TS2322: Type 'ReactElement<any, string | JSXElementConstructor<any>> | (() => ReactElement<any, string | JSXElementConstructor<any>>)' is not assignable to type 'ReactNode'.
  Type '() => React.ReactElement<any, string | React.JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
Error: src/component/feature/FeatureStrategy/FeatureStrategyCreate/FeatureStrategyCreate.tsx(248,17): error TS2322: Type 'Element | null' is not assignable to type 'Element | undefined'.
Error: src/component/layout/Error/Error.tsx([5](https://github.com/Unleash/unleash/actions/runs/10350980657/job/28648500408?pr=7825#step:9:6)3,17): error TS2322: Type 'Element | null' is not assignable to type 'Element | undefined'.
  Type 'null' is not assignable to type 'Element | undefined'.
Error: src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/SegmentExecution/SegmentExecution.tsx(40,25): error TS2322: Type 'Element | null' is not assignable to type 'Element | undefined'.
  Type 'null' is not assignable to type 'Element | undefined'.
Error: src/component/project/Project/ProjectHealth/ReportTable/ReportCard/ReportCard.tsx(152,25): error TS2322: Type '(() => Element) | null' is not assignable to type 'ReactNode'.
  Type '() => JSX.Element' is not assignable to type 'ReactNode'.
Error: src/component/project/Project/ProjectHealth/ReportTable/ReportCard/ReportCard.tsx(1[6](https://github.com/Unleash/unleash/actions/runs/10350980657/job/28648500408?pr=7825#step:9:7)1,25): error TS2322: Type '(() => Element) | null' is not assignable to type 'ReactNode'.
  Type '() => JSX.Element' is not assignable to type 'ReactNode'.
Error: src/component/project/Project/ProjectHealth/ReportTable/ReportCard/ReportCard.tsx(1[7](https://github.com/Unleash/unleash/actions/runs/10350980657/job/28648500408?pr=7825#step:9:8)4,25): error TS2322: Type '(() => Element) | null' is not assignable to type 'ReactNode'.
  Type '() => JSX.Element' is not assignable to type 'ReactNode'.
Error: Process completed with exit code 2.

Copy link

vercel bot commented Aug 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 11:02am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Aug 30, 2024 11:02am

Copy link
Contributor

github-actions bot commented Aug 12, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@@ -55,6 +55,7 @@ export const Error: VFC<IErrorProps> = ({ error }) => {
<ConditionallyRender
condition={showZendeskButton}
show={<ZendeskButton />}
elseShow={undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's more idiomatic to return null than undefined in react. I checked the code and the ConditionallyRender swaps undefined to null under the hood but in the spirit of "don't make me think" I'd go for null here.

Copy link
Contributor

@kwasniew kwasniew Aug 30, 2024

Choose a reason for hiding this comment

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

Same for the other places where we follow this pattern

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but in this place prop customButton expects something || undefined

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah so it's for the next step of the migration when we do codemods. Those things are worth mentioning in the PR description since it's not obvious.

@Tymek Tymek merged commit 79fccbd into main Aug 30, 2024
9 of 11 checks passed
@Tymek Tymek deleted the fix/render-props branch August 30, 2024 11:39
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.

2 participants