-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
add types #4592
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
cdc74f9
to
366e188
Compare
There was a problem hiding this 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.
There was a problem hiding this 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.
94e3079
to
363cbb6
Compare
There was a problem hiding this 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!
Reviewed with ❤️ by PullRequest
types/types.tests.tsx
Outdated
}, | ||
fn(state: MiddlewareState): MiddlewareReturn { | ||
if (state.placement === "top") { | ||
console.log("Popper is on the top"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types/types.tests.tsx
Outdated
weekLabel="" | ||
withPortal | ||
portalId="" | ||
portalHost={document.body.shadowRoot!} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review.
I agree and will edit the md file.
I agree with you. |
There was a problem hiding this 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:
There was a problem hiding this 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.
Reviewed with ❤️ by PullRequest
types/types.tests.tsx
Outdated
ref={(instance) => { | ||
if (instance !== null) { | ||
// $ExpectType ReactDatePicker<true> | ||
instance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
@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. |
@martijnrusschen 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. |
Thanks, will wait for the recommended updated. |
There was a problem hiding this 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:
@martijnrusschen |
There was a problem hiding this 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:
363cbb6
to
3463c13
Compare
3463c13
to
e7ef315
Compare
e7ef315
to
82582d0
Compare
I did CI tweaks, Lint error handling, and md file corrections. |
Sorry, but I'm going to have to rethink the idea once and I'll make it a draft. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.
This is a bold idea, but maybe we should consider adopting TS instead of just merging the repo with 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 |
Yes agree, I'm open to it but don't have the time to get this going. Open to suggestions. |
What path I see:
|
I can prepare a draft of the migration issue |
@mirus-ua sounds good! |
@martijnrusschen here is the draft, let's discuss it inside the issue #4700 |
#4700 is supported so that the type definitions will be output, and this PR will be closed. |
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