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

[typescript-migration] month.jsx #4743

Merged
merged 4 commits into from
May 3, 2024

Conversation

mirus-ua
Copy link
Contributor


name: Migrate month.jsx

Description

Linked issue: #4700

Changes
month.jsx was migrated to ts + added JSDocs

Contribution checklist

  • I have followed the contributing guidelines.
  • I have added sufficient test coverage for my changes.
  • I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.85%. Comparing base (0cb6f84) to head (860ab02).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4743      +/-   ##
==========================================
- Coverage   97.26%   96.85%   -0.42%     
==========================================
  Files          11       10       -1     
  Lines        1462     1143     -319     
  Branches      642      513     -129     
==========================================
- Hits         1422     1107     -315     
+ Misses         40       36       -4     

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

@mirus-ua
Copy link
Contributor Author

@martijnrusschen hello, it looks like pullrequest stack, because I don't see it as a reviewer

@martijnrusschen
Copy link
Member

martijnrusschen commented Apr 29, 2024 via email

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@mirus-ua you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 423
- 226

97% TSX
3% TypeScript

Type of change

Feature - These changes are adding a new feature or improvement to existing code.
1 Message
⚠️ Due to its size, this pull request will likely have a little longer turnaround time and will probably require multiple passes from our reviewers.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

this looks like a fairly simple change to do things in a more TS way. Are there any unit tests for this that need to be modified as well?

Image of Andy W Andy W


Reviewed with ❤️ by PullRequest

@@ -845,8 +845,7 @@ export function isMonthDisabled(
minDate: minDate ? startOfMonth(minDate) : undefined,
maxDate: maxDate ? endOfMonth(maxDate) : undefined,
}) ||
(excludeDates &&
excludeDates.some((excludeDate) => isSameMonth(month, excludeDate))) ||
excludeDates?.some((excludeDate) => isSameMonth(month, excludeDate)) ||
Copy link

Choose a reason for hiding this comment

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

i get why this looks cleaner but is it necessary?

🔹 Simplify Code (Nice to have)

Image of Andy W Andy W

Copy link

Choose a reason for hiding this comment

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

I believe this could introduce a functional change and should be verified carefully. The original statement includes the logical AND operator (&&) to first check if excludeDates is truthy (i.e., not null, undefined, false, 0, NaN, or an empty string). The modified statement uses the optional chaining operator (?.) to call .some() on excludeDates only if excludeDates is not null or undefined.

The key difference here is the return value when excludeDates is null or undefined: it is undefined rather than false as in the previous case. This distinction could affect how the expression behaves in a broader logic context where undefined and false might be handled differently.

Image of Jonah S Jonah S

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think someone considered false values in this case. Moreover, our types clearly say that we have only two options: Date[] or undefined.
Last but not least, all tests are green, and right now, this is a source of truth w/o other documentation and specs.

Copy link

Choose a reason for hiding this comment

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

Thanks for double checking that to ensure there isn't a change in behavior!

Image of Jonah S Jonah S

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

I have marked this as approved, but want to request you review the comments on the potential behavior change in excludeDates to ensure the functionality is not changing unexpectedly. Thank you!

Image of Jonah S Jonah S


Reviewed with ❤️ by PullRequest

@@ -942,8 +938,7 @@ export function isYearDisabled(
minDate: minDate ? startOfYear(minDate) : undefined,
maxDate: maxDate ? endOfYear(maxDate) : undefined,
}) ||
(excludeDates &&
excludeDates.some((excludeDate) => isSameYear(date, excludeDate))) ||
excludeDates?.some((excludeDate) => isSameYear(date, excludeDate)) ||
(includeDates &&
Copy link

Choose a reason for hiding this comment

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

If you are simplifying the excludeDates code, it would be ideal to simplify the includeDates code in the same fashion. This issue occurs in more than just this one place, FYI.

🔹 Style Consistency (Nice to have)

Image of Jonah S Jonah S

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't touch includeDates because of !. In this case is hard to separate missing values and some method result revertion.

includeDates &&
      !includeDates.some((includeDate) => isSameYear(date, includeDate)))

Copy link

Choose a reason for hiding this comment

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

Ok, that makes sense considering the negation in that line vs. the excludeDates line. Thank you!

Image of Jonah S Jonah S

@@ -1504,7 +1499,9 @@
* @param event - The keyboard event.
* @returns - Returns true if the space key was pressed down, false otherwise.
*/
export function isSpaceKeyDown(event: KeyboardEvent): boolean {
export function isSpaceKeyDown(
event: React.KeyboardEvent<HTMLDivElement>,
Copy link

Choose a reason for hiding this comment

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

I like that you made this event more specific to handle keyboard events in a way that is consistent with React's event handling conventions and optimizations.

◽ Compliment

Image of Jonah S Jonah S

@martijnrusschen martijnrusschen merged commit 85843e8 into Hacker0x01:main May 3, 2024
5 of 6 checks passed
@mirus-ua mirus-ua deleted the feature/ts/month.jsx branch May 3, 2024 14:18
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