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

add types #4592

Closed
wants to merge 6 commits into from
Closed

add types #4592

wants to merge 6 commits into from

Conversation

yuki0410-dev
Copy link
Contributor

@yuki0410-dev yuki0410-dev commented Mar 14, 2024

Description

Linked issue: #4587

Problem

Changes

Screenshots

To reviewers

Merging and releasing this PR will allow react-datepicker type completion to work without installing @types/react-datepicker.
You will also see the TS icon (painted blue) on npmjs.com.

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

@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 not sent to the PullRequest network because the pull request is a draft.

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.96%. Comparing base (5261cbd) to head (82582d0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4592   +/-   ##
=======================================
  Coverage   96.96%   96.96%           
=======================================
  Files          28       28           
  Lines        2601     2601           
  Branches     1095     1095           
=======================================
  Hits         2522     2522           
  Misses         79       79           

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

@yuki0410-dev yuki0410-dev force-pushed the feat/add-types branch 2 times, most recently from cdc74f9 to 366e188 Compare March 14, 2024 14:59
@yuki0410-dev yuki0410-dev marked this pull request as ready for review March 14, 2024 15:02
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.


@yuki0410-dev 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

+ 619
- 0

47% TSX (tests)
38% TypeScript
7% GitHubActions
3% JSON with Comments
5% Other

Generated lines of change

+ 8
- 0

Type of change

Feature - These changes are adding a new feature or improvement to existing code.

@yuki0410-dev yuki0410-dev force-pushed the feat/add-types branch 2 times, most recently from 94e3079 to 363cbb6 Compare March 14, 2024 16:01
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.

Having read the associated issue for this PR, this sounds like a good idea to me. I'd definitely love to see more proper TypeScript support for this library (for those who wish to use it).

The implementation itself also seems fine to me. I had 2 minor comments below. But overall, the PR is introducing:

  • TypeScript tests to catch any type errors
  • A GitHub workflow to run these tests
  • The type declaration file itself

My only other suggestion would be to find any instances in the README or elsewhere (e.g., documentation) that involve notes on contributing, and mention that TypeScript types should be updated when making relevant changes. A good example of this is actually your recent PR (#4553).

The primary maintainers of this repository will need to have the final say on supporting TypeScript at this level. I think it seems like a beneficial addition to the project, but we will have to wait for their feedback before finalizing this.

Having said that, thanks for this contribution and for all of the excellent contributions you've been making lately to improve this library. It's very appreciated!

Image of Ryan Ryan


Reviewed with ❤️ by PullRequest

},
fn(state: MiddlewareState): MiddlewareReturn {
if (state.placement === "top") {
console.log("Popper is on the top");
Copy link

Choose a reason for hiding this comment

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

ISSUE: no-console (Severity: Medium)
Unexpected 'console' statement.

Remediation:
Could this console.log statement be removed?

🤖 powered by PullRequest Automation 👋 verified by Ryan

weekLabel=""
withPortal
portalId=""
portalHost={document.body.shadowRoot!}
Copy link

@pullrequest pullrequest bot Mar 14, 2024

Choose a reason for hiding this comment

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

ISSUE: @typescript-eslint/no-non-null-assertion (Severity: Low)
Forbidden non-null assertion.

Remediation:
Could we please avoid using type assertions? This should be checkable in advance.

🤖 powered by PullRequest Automation 👋 verified by Ryan

🔸 Best Practices (Important)

Image of Ryan Ryan

@yuki0410-dev
Copy link
Contributor Author

Thanks for the review.

My only other suggestion would be to find any instances in the README or elsewhere (e.g., documentation) that involve notes on contributing, and mention that TypeScript types should be updated when making relevant changes. A good example of this is actually your recent PR (#4553).

I agree and will edit the md file.

The primary maintainers of this repository will need to have the final say on supporting TypeScript at this level. I think it seems like a beneficial addition to the project, but we will have to wait for their feedback before finalizing this.

I agree with you.
I would be happy if the main maintainer of this repository would understand the advantages and disadvantages of this PR and adopt it.

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 reviewed the updates made to #4592 since our last review was posted. This includes comments that have been posted by non-PullRequest reviewers. No further issues were found.

Reviewed by:

Image of Ryan Ryan

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 change looks good, just one comment for a line that looks suspicious.

Image of Jacques Jacques


Reviewed with ❤️ by PullRequest

ref={(instance) => {
if (instance !== null) {
// $ExpectType ReactDatePicker<true>
instance;
Copy link

Choose a reason for hiding this comment

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

ISSUE: @typescript-eslint/no-unused-expressions (Severity: Medium)
Expected an assignment or function call and instead saw an expression.

Remediation:
Should this function return something?

🤖 powered by PullRequest Automation 👋 verified by Jacques

Copy link

Choose a reason for hiding this comment

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

Understandable to raise this as a comment, but I actually deliberately didn't flag this one. This is normal when writing tests specifically for the type system.

The idea is to just produce a bunch of statements and see if they emit type errors.

If you look at the rest of the file, this will make more sense, since you'll see a bunch of disparate JSX as well.

Image of Ryan Ryan

@martijnrusschen
Copy link
Member

@yuki0410-dev I'm not an expert, but I understand the benefits of supporting this. Is there any reason why these definitions are also maintained in a separate repo like you linked? I guess that's the same of what we're now adding in this repo.

@yuki0410-dev
Copy link
Contributor Author

@martijnrusschen
Thank you for your understanding regarding TS support.

When this PR is released, users of later versions will no longer need to use @types/react-datepicker. However, the current version of @types/react-datepicker must be retained for users of versions prior to that release. (No further updates will be made.)

Initially there is no difference between the two repositories, but each time a parameter such as Props is added in this repository, it will be reflected in the types in this repository, and the difference between the two repositories will become larger and larger.

In this case, we are adding the type usePointerEvent as an example.
363cbb6

@martijnrusschen
Copy link
Member

Thanks, will wait for the recommended updated.

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 reviewed the updates made to #4592 since our last review was posted. This includes comments that have been posted by non-PullRequest reviewers. No further issues were found.

Reviewed by:

Image of Ryan Ryan

@yuki0410-dev
Copy link
Contributor Author

@martijnrusschen
Thank you for your understanding.
I will make the corrections pointed out by linter and add the documentation.

@yuki0410-dev yuki0410-dev marked this pull request as draft March 17, 2024 14:53
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 reviewed the updates made to #4592 since our last review was posted. This includes comments that have been posted by non-PullRequest reviewers. No further issues were found.

Reviewed by:

Image of Ryan Ryan

@yuki0410-dev yuki0410-dev marked this pull request as ready for review March 19, 2024 16:51
@yuki0410-dev
Copy link
Contributor Author

I did CI tweaks, Lint error handling, and md file corrections.

@yuki0410-dev yuki0410-dev marked this pull request as draft March 20, 2024 03:46
@yuki0410-dev
Copy link
Contributor Author

Sorry, but I'm going to have to rethink the idea once and I'll make it a draft.

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 reviewed the updates made to #4592 up until the latest commit (82582d0). No further issues were found.

Reviewed by:

Image of Ryan Ryan

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.

Due to inactivity, PullRequest has cancelled this review job. You can reactivate the code review job from the PullRequest dashboard.

@mirus-ua
Copy link
Contributor

This is a bold idea, but maybe we should consider adopting TS instead of just merging the repo with .d.ts?

This is almost impossible to do at once, but with a proper community road map, we can do it for all files individually. Moreover, the most important part is the datepicker itself, and docs and even tests can stay written in js for any amount of time

@martijnrusschen
Copy link
Member

Yes agree, I'm open to it but don't have the time to get this going. Open to suggestions.

@mirus-ua
Copy link
Contributor

What path I see:

@mirus-ua
Copy link
Contributor

I can prepare a draft of the migration issue

@martijnrusschen
Copy link
Member

@mirus-ua sounds good!

@mirus-ua
Copy link
Contributor

@martijnrusschen here is the draft, let's discuss it inside the issue #4700

@yuki0410-dev
Copy link
Contributor Author

#4700 is supported so that the type definitions will be output, and this PR will be closed.

@yuki0410-dev yuki0410-dev deleted the feat/add-types branch May 14, 2024 15:32
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.

3 participants