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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: investigate type error with mode prop #1583

Open
gpbl opened this issue Oct 12, 2022 · 0 comments 路 May be fixed by #1718
Open

types: investigate type error with mode prop #1583

gpbl opened this issue Oct 12, 2022 · 0 comments 路 May be fixed by #1718
Labels
Type: Feature New Feature
Milestone

Comments

@gpbl
Copy link
Owner

gpbl commented Oct 12, 2022

  Hi! I'm not opening new issue because I think it can be somehow related with this one 馃檪 

So, after updating to 8.3.1 this issue appeared:
Screenshot 2022-10-05 at 12 00 00

mode and selectedDate comes from props. Their types are defined as follows:

mode?: 'single' | 'multiple' | 'range';
selectedDate: DatesType

(and DatesType: Date | Date[] | DateRange | undefined, where DateRange is imported from `react-day-picker)

At this point I ran out of ideas how to resolve this issue. The only solution that worked, was something like this:

{ mode === 'single' && <DayPicker mode='single' selected={selectedDate as Date | undefined} {...otherProps} /> }
{ mode === 'multiple' && <DayPicker mode='multiple' selected={selectedDate as Date[] | undefined} {...otherProps} /> }
{ mode === 'range' && <DayPicker mode='range' selected={selectedDate as DateRange | undefined} {...otherProps} /> }

but to be hones it doesn't look too clean.

Maybe you would know what is the issue here and if there is a better way to resolve it than the one I showed above?

Thanks in advance 馃槂

Originally posted by @bartlomiej-bykowy in #1570 (comment)

@gpbl gpbl changed the title Investigate mode type errors types: investigate type error with mode prop Jan 25, 2023
ongyuxing added a commit to ongyuxing/react-day-picker that referenced this issue Mar 8, 2023
ongyuxing added a commit to ongyuxing/react-day-picker that referenced this issue Mar 8, 2023
@ongyuxing ongyuxing linked a pull request Mar 8, 2023 that will close this issue
@gpbl gpbl linked a pull request Mar 8, 2023 that will close this issue
@gpbl gpbl added the Status: In Progress Work in Progress label Apr 9, 2023
@gpbl gpbl added this to the v9 milestone Apr 14, 2023
@gpbl gpbl added Type: Feature New Feature and removed Status: In Progress Work in Progress labels Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New Feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant