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

[BUG] selectMultiples types causing typescript error #4999

Open
fzn0x opened this issue Jul 22, 2024 · 2 comments
Open

[BUG] selectMultiples types causing typescript error #4999

fzn0x opened this issue Jul 22, 2024 · 2 comments

Comments

@fzn0x
Copy link

fzn0x commented Jul 22, 2024

Type '{ selected: Date; onChange: (date: [Date, Date]) => void; portalId: string; locale: string; showTimeSelect: true; timeFormat: string; timeIntervals: number; dateFormat: string; customInput: Element; }' is not assignable to type 'IntrinsicAttributes & (IntrinsicClassAttributes<DatePicker> & ((Pick<Readonly<Omit<CalendarProps, "dropdownMode" | ... 19 more ... | "outsideClickIgnoreClass"> & ... 5 more ... & { ...; }>, "date" | ... 107 more ... | "onChangeRaw"> & InexactPartial<...> & InexactPartial<...>) | (Pick<...> & ... 1 more ... & Inexact...'.
  Property 'selectsMultiple' is missing in type '{ selected: Date; onChange: (date: [Date, Date]) => void; portalId: string; locale: string; showTimeSelect: true; timeFormat: string; timeIntervals: number; dateFormat: string; customInput: Element; }' but required in type 'Pick<Readonly<Omit<CalendarProps, "dropdownMode" | "onSelect" | "setOpen" | "dateFormat" | "preSelection" | "setPreSelection" | "selectsRange" | "handleOnKeyDown" | ... 12 more ... | "outsideClickIgnoreClass"> & ... 5 more ... & { ...; }>, "date" | ... 107 more ... | "onChangeRaw">'.ts(2322)
index.d.ts(94, 5): 'selectsMultiple' is declared here.
<DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      portalId="root-portal"
      locale="pt-BR"
      showTimeSelect
      timeFormat="p"
      timeIntervals={15}
      dateFormat="Pp"
      customInput={<InputDate />}
    />

Screenshot 2024-07-22 191218

jossi87 added a commit to jossi87/climbing-web that referenced this issue Jul 24, 2024
@Svish
Copy link
Contributor

Svish commented Jul 31, 2024

I got this too, and think I fixed it by being explicit in the onChange callback: onChange={(date: Date | null) => setStartDate(date)}

@RammasEchor
Copy link

RammasEchor commented Aug 8, 2024

Same error here. onChange={(date: Date | null) => setStartDate(date)} works, but I would prefer not to have my variables declared as date: Date | null. I got this: onChange={(date: Date | null) => date ? setStartDate(date) : null}

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

No branches or pull requests

3 participants