react-datepicker
react-datepicker copied to clipboard
[milestone] Convert the library to typescript
Contribution is welcome
Why?
Everything started here from the willing to merge a separate package with the corresponding type definitions into this repo. The idea is great, but we, as a community, can go further and migrate the entire code base into typescript.
Any benefits?
- only one package to install for end users
- easier to maintain
- your help to the lovely library
- ???
- profit
Our steps to achieve the goal
- [x] extend rollup and rest tools to support
.ts
and.tsx
modules https://github.com/Hacker0x01/react-datepicker/pull/4704 - [x] migrate datepicker modules first
- [x] add a GitHub action to check types @mirus-ua https://github.com/Hacker0x01/react-datepicker/pull/4749
- [ ] update docs
- [x] migrate test cases
- [x] use
ts-jest
@mirus-ua - [ ] migrate docs (optional)
Modules to migrate and how to contribute
Basic rules and advice:
- start with the smallest isolated modules, like
calendar_container.jsx
- prevent the use
any
or other loose types if you don't have strong arguments - prevent using "slow types", give this option to the end users
- use interfaces instead of types because the large amount of the code base is class-based
- add JSDocs where you can to improve overall DX. Everyone likes a good DX
Steps to contribute
- Write in the comments the name of the module that you want help to migrate
- Me or a maintainer will assign your name to the list to prevent doing the same job twice
- Migrate according to the list of advice above
- Highly recommended to migrate test cases together with the module
- Create a PR with a name format
[typescript-migration] calendar.jsx
etc.
- [x] calendar_icon.jsx https://github.com/Hacker0x01/react-datepicker/pull/4706
- [x] calendar_container.tsx https://github.com/Hacker0x01/react-datepicker/pull/4704
- [x] date_utils.js https://github.com/Hacker0x01/react-datepicker/pull/4707
- [x] inputTime.jsx https://github.com/Hacker0x01/react-datepicker/pull/4708
- [x] calendar.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4766
- [x] popper_component.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4740
- [x] week_number.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4714
- [x] month.jsx @mirus-ua https://github.com/Hacker0x01/react-datepicker/pull/4743
- [x] portal.jsx @Olenka-Yurchuk https://github.com/Hacker0x01/react-datepicker/pull/4722
- [x] with_floating.jsx https://github.com/Hacker0x01/react-datepicker/pull/4709
- [x] month_dropdown.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4723
- [x] year.jsx @Olenka-Yurchuk https://github.com/Hacker0x01/react-datepicker/pull/4756
- [x] month_dropdown_options.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4723
- [x] tab_loop.jsx https://github.com/Hacker0x01/react-datepicker/pull/4710
- [x] year_dropdown.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4715
- [x] day.jsx @mirus-ua https://github.com/Hacker0x01/react-datepicker/pull/4713
- [x] month_year_dropdown.jsx https://github.com/Hacker0x01/react-datepicker/pull/4724
- [x] time.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4726
- [x] year_dropdown_options.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4715
- [x] index.jsx @yuki0410-dev https://github.com/Hacker0x01/react-datepicker/pull/4766
- [x] month_year_dropdown_options.jsx https://github.com/Hacker0x01/react-datepicker/pull/4724
- [x] week.jsx https://github.com/Hacker0x01/react-datepicker/pull/4725 https://github.com/Hacker0x01/react-datepicker/pull/4725
Breaking changes so far:
@martijnrusschen can you pin the issue?
Nice progress so far!
@mirus-ua ( @martijnrusschen ) Thank you for the great attempt. I would like to help as well, but should I declare the file to be started on this issue?
refs #4000
@yuki0410-dev Feel free to claim a file and let it know here so there's no duplicate work done.
@yuki0410-dev hello Yes, grab anything, the only one piece of advice is to pick modules without dependencies or with dependencies only on typescript modules, because it won't be pleasant to combine them later
I would like to take the portal jsx file in work
I would like to take the week_number.jsx file in work
Added your name to week_number.jsx
6.6% 💪
@mirus-ua I would like to take the year_dropdown.jsx and year_dropdown_options.jsx file in work.
@mirus-ua I would like to take the month_dropdown.jsx and month_dropdown_options.jsx file in work.
@martijnrusschen hello. Please ask reviews to look at four opened PRs if you can. It'll be much faster if we merge them because the rest of the modules depend on them
Yep, I'll expect them to complete this soon. Normal turnaround time is ~2-4 hours.
@mirus-ua I would like to take the month_year_dropdown.jsxand month_year_dropdown_options.jsx file in work.
@mirus-ua I would like to take the week.jsx file in work.
@mirus-ua I would like to take the time.jsx file in work.
@mirus-ua I would like to take the year.jsx file in work.
@mirus-ua I would like to take the popper_component.jsx file in work.
@mirus-ua I would like to take the calendar.jsx file in work.
@mirus-ua Modifications to index.jsx may need to be synchronized with modifications to calendar.jsx. (especially the props type) Would it be ok if I work on it all together?
@mirus-ua Modifications to index.jsx may need to be synchronized with modifications to calendar.jsx. (especially the props type) Would it be ok if I work on it all together?
sure, I think you should wait a bit for the month and the year modules
@mirus-ua
sure, I think you should wait a bit for the month and the year modules
I agree with waiting too. We are moving forward on the calendar.jsx work, but there are some aspects that we cannot move forward on until those are completed.
apologies, I'm on vacation this week and don't have the ability to review or merge anything until Friday.
On Mon, Apr 29, 2024 at 3:15 PM yuki0410 @.***> wrote:
@mirus-ua https://github.com/mirus-ua
sure, I think you should wait a bit for the month and the year modules
I agree with waiting too. We are moving forward on the calendar.jsx work, but there are some aspects that we cannot move forward on until those are completed.
— Reply to this email directly, view it on GitHub https://github.com/Hacker0x01/react-datepicker/issues/4700#issuecomment-2082714610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKY2KE7BIGCPH4IGIOERD3Y7ZBWDAVCNFSM6AAAAABGK5XR6KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBSG4YTINRRGA . You are receiving this because you were mentioned.Message ID: @.***>
@yuki0410-dev almost everything was merged, so you can start with the final part
what's left?
@mirus-ua (@martijnrusschen ) I would like to take the week_picker_test.test.js file in work. and fix some types.
what's left?
The core features are done.But I think better to migrate some amount of tests just to double check that all types are OK
@mirus-ua I noticed during my experimentation with #4810 that type errors in the test file do not seem to result in errors in CI. Is it my understanding that this is due to the fact that I am now using babel-jest to run tests with type information ignored, and that when I change to ts-jest later on, I will get CI errors?
@mirus-ua I noticed during my experimentation with #4810 that type errors in the test file do not seem to result in errors in CI. Is it my understanding that this is due to the fact that I am now using babel-jest to run tests with type information ignored, and that when I change to ts-jest later on, I will get CI errors?
everything is correct