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

chore: migrate ErrorBoundary component from jsx to tsx #17908

Closed

Conversation

Damans227
Copy link
Contributor

SUMMARY

PR for migrating ErrorBoundary class based react component from JSX to TSX

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • [TRACKER] Migrate JavaScript files to TypeScript #10004
  • Enhancement (new features, refinement)
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

SOURCES REFFERED

@codecov
Copy link

codecov bot commented Jan 3, 2022

Codecov Report

Merging #17908 (b36ca8b) into master (4954d52) will decrease coverage by 0.73%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17908      +/-   ##
==========================================
- Coverage   67.08%   66.34%   -0.74%     
==========================================
  Files        1609     1568      -41     
  Lines       64897    61502    -3395     
  Branches     6866     6241     -625     
==========================================
- Hits        43533    40803    -2730     
+ Misses      19498    19101     -397     
+ Partials     1866     1598     -268     
Flag Coverage Δ
javascript 50.91% <100.00%> (-2.86%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rontend/src/components/ErrorMessage/ErrorAlert.tsx 89.47% <ø> (-1.64%) ⬇️
...onents/ErrorMessage/ErrorMessageWithStackTrace.tsx 50.00% <ø> (-16.67%) ⬇️
...et-frontend/src/components/ErrorBoundary/index.tsx 80.00% <100.00%> (ø)
superset-frontend/src/components/Slider/index.tsx 0.00% <0.00%> (-75.00%) ⬇️
.../src/explore/components/controls/HiddenControl.tsx 0.00% <0.00%> (-75.00%) ⬇️
...t-frontend/src/filters/components/GroupBy/index.ts 0.00% <0.00%> (-66.67%) ⬇️
...ntend/src/filters/components/GroupBy/buildQuery.ts 0.00% <0.00%> (-66.67%) ⬇️
...end/src/filters/components/TimeGrain/buildQuery.ts 0.00% <0.00%> (-66.67%) ⬇️
...nd/src/filters/components/TimeColumn/buildQuery.ts 0.00% <0.00%> (-66.67%) ⬇️
...ols/DateFilterControl/components/CalendarFrame.tsx 0.00% <0.00%> (-42.86%) ⬇️
... and 499 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4954d52...b36ca8b. Read the comment docs.

@Damans227
Copy link
Contributor Author

Damans227 commented Jan 8, 2022

@etr2460 Ptal, thx! Also, Happy New Year.

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

2 questions and a comment

@@ -82,7 +82,7 @@ const LeftSideContent = styled.div`

interface ErrorAlertProps {
body: ReactNode;
copyText?: string;
copyText?: string | JSX.Element;
Copy link
Member

Choose a reason for hiding this comment

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

is this change intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the typescript infers const message on line 52 as a JSX.Element.

Screen Shot 2022-01-14 at 8 54 54 PM

Copy link
Contributor Author

@Damans227 Damans227 Jan 15, 2022

Choose a reason for hiding this comment

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

Type for copyText becomes invalid if type JSX.Element is not set. Following error gets thrown in the ErrorMessageWithStack Component and the index.tsx file eventually:

(JSX attribute) copyText?: string | undefined
Type 'Element' is not assignable to type 'string'.ts(2322)
ErrorMessageWithStackTrace.tsx(33, 3): The expected type comes from property 'copyText' which is declared here on type 'IntrinsicAttributes & Props' 

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, thanks!

@@ -30,8 +30,8 @@ type Props = {
error?: SupersetError;
link?: string;
subtitle?: React.ReactNode;
copyText?: string;
stackTrace?: string;
copyText?: string | JSX.Element;
Copy link
Member

Choose a reason for hiding this comment

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

same question here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same reason as above

superset-frontend/src/components/ErrorBoundary/index.tsx Outdated Show resolved Hide resolved
@Damans227 Damans227 force-pushed the enhancement/migrate-jsx-to-tsx_9 branch from 00b7706 to 95609cc Compare January 15, 2022 02:29
@Damans227 Damans227 force-pushed the enhancement/migrate-jsx-to-tsx_9 branch from 95609cc to b36ca8b Compare January 15, 2022 02:48
@@ -82,7 +82,7 @@ const LeftSideContent = styled.div`

interface ErrorAlertProps {
body: ReactNode;
copyText?: string;
copyText?: string | JSX.Element;
Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, thanks!

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 16, 2022
@stale stale bot closed this Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants