gpbl / react-day-picker

DayPicker is a customizable date picker component for React. Add date pickers, calendars, and date inputs to your web applications.

Home Page:https://daypicker.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Extending DayPickerProps causes typescript errors

pekarja5 opened this issue · comments

Bug description

Modification of DayPickerProps causes typescript to fail with Type error: Expression produces a union type that is too complex to represent.

To reproduce

Try to create new type by using the provided type.

type DatepickerProps = Omit<DayPickerProps, 'locale'> & {
	locale?: LocaleType;
};

Steps

  1. Create new type based on DayPickerProps
  2. Try to compile the code

Thanks! Maybe related to #1718?

I was thinking if this change isn't the problem:
018c722#diff-3c1e8063978b6b28fc6cc3290e71ae52eb91d50bf5963c42b787829f61c1a19dR35
as the Omit is trying to exclude something from an infinite number of keys. But my typescript knowledge is not as deep to be sure of it.

@pekarja5 yes you were right – that was the bug.

I published the fix in https://github.com/gpbl/react-day-picker/releases/tag/v8.7.1, please report back if you still have issues. Thanks!