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

Migrate remaining components to TypeScript #2065

Merged
merged 7 commits into from
Apr 26, 2023
Merged

Conversation

connor-baer
Copy link
Member

@connor-baer connor-baer commented Apr 25, 2023

Completes #516.

Purpose

While working on #2061, I encountered an issue with the remaining JavaScript files. Files that contain JSX need to use the .jsx extension. ESM requires imports to include the filename and extension. However, once TypeScript transpiles the files using the "jsx": "react-jsx" config option, it uses the .js file extension on disk but doesn't update the imports to match.

This isn't an issue for TypeScript files, where the final extension should be used for imports (i.e., .js).

Approach and changes

  • Migrate the AspectRatio, Calendar, Tabs, Carousel, and Sidebar components to TypeScript. Most of these are deprecated or need a rewrite, so I kept the refactor to a minimum. Many issues remain.
  • Removed the remaining shared proptypes and removed the prop-types dependency

Definition of done

  • Development completed
  • Reviewers assigned
  • Unit and integration tests
  • Meets minimum browser support
  • Meets accessibility requirements

@changeset-bot
Copy link

changeset-bot bot commented Apr 25, 2023

🦋 Changeset detected

Latest commit: 26db23e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sumup/circuit-ui Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Apr 25, 2023

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

Name Status Preview Comments Updated (UTC)
oss-circuit-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2023 6:50am

@codecov
Copy link

codecov bot commented Apr 25, 2023

Codecov Report

Merging #2065 (26db23e) into next (fef5b95) will decrease coverage by 0.30%.
The diff coverage is 91.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #2065      +/-   ##
==========================================
- Coverage   97.10%   96.81%   -0.30%     
==========================================
  Files         250      248       -2     
  Lines       22392    22383       -9     
  Branches     2105     2117      +12     
==========================================
- Hits        21743    21669      -74     
- Misses        641      703      +62     
- Partials        8       11       +3     
Impacted Files Coverage Δ
...rcuit-ui/components/Carousel/__fixtures__/index.ts 100.00% <ø> (ø)
...ui/components/Carousel/components/Buttons/index.ts 100.00% <ø> (ø)
...t-ui/components/Calendar/RangePickerController.tsx 51.42% <25.00%> (ø)
...mponents/CalendarTagTwoStep/CalendarTagTwoStep.tsx 52.06% <46.34%> (ø)
.../circuit-ui/components/CalendarTag/CalendarTag.tsx 56.93% <66.00%> (ø)
.../circuit-ui/components/AspectRatio/AspectRatio.tsx 100.00% <100.00%> (ø)
...ackages/circuit-ui/components/AspectRatio/index.ts 100.00% <100.00%> (ø)
...ges/circuit-ui/components/Calendar/RangePicker.tsx 90.00% <100.00%> (ø)
...circuit-ui/components/Calendar/SingleDayPicker.tsx 100.00% <100.00%> (ø)
...dar/components/CalendarWrapper/CalendarWrapper.tsx 100.00% <100.00%> (ø)
... and 29 more

... and 1 file with indirect coverage changes

Comment on lines -4 to -10
.circuit-0 {
display: block;
position: relative;
overflow: hidden;
height: auto;
width: 100%;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed these default styles when no aspect-ratio is provided. The result should be the same.

{this.getDateRangePreview()}
</Tag>
{isOpen && (
<CalendarWrap>
<RangePickerController
initialVisibleMonth={null}
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this to make TypeScript happy. The component works the same with and without 🤷‍♂️

onClick={this.handleTagClick}
>
{this.getDateRangePreview()}
</Tag>
{isOpen && (
<CalendarWrapper>
{/* @ts-expect-error This worked before the component was converted to TypeScript */}
Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't bother fixing the types here since the component will soon be replaced.

@@ -64,17 +112,17 @@ const animationStyles = ({
animation-name: ${animationName};
animation-duration: ${animationDuration}ms;
animation-fill-mode: forwards;
animation-timing-function: ${theme.transitions.easeInOutCubic};
Copy link
Member Author

Choose a reason for hiding this comment

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

This transition doesn't exist on the theme (anymore?).

@connor-baer connor-baer marked this pull request as ready for review April 26, 2023 06:49
@connor-baer connor-baer requested a review from a team as a code owner April 26, 2023 06:49
@connor-baer connor-baer requested review from tareqlol and removed request for a team April 26, 2023 06:49
Copy link
Contributor

@tareqlol tareqlol left a comment

Choose a reason for hiding this comment

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

That's nice! Good work⭐

@connor-baer connor-baer mentioned this pull request Apr 26, 2023
5 tasks
Copy link
Contributor

@robinmetral robinmetral left a comment

Choose a reason for hiding this comment

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

Wow! This is great, thanks for doing it. It's true that we were in a bit of a tricky situation, with legacy components that we didn't bother migrating to TS initially, but also blocked by these very components when cleaning up/improving our stack.

I haven't looked at the full diff very closely since many of these components are either legacy or have low usage. There will definitely be type errors in consumer apps, but we can probably @ts-ignore many of them during the migration—since these components should eventually be replaced (or rebuilt) anyway.

In a word: fantastisch

@connor-baer connor-baer merged commit 8adb8fe into next Apr 26, 2023
@connor-baer connor-baer deleted the typescript-all-the-things branch April 26, 2023 17:20
This was referenced Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants