diff --git a/src/calendar.tsx b/src/calendar.tsx index 664b35be2..d80f1554a 100644 --- a/src/calendar.tsx +++ b/src/calendar.tsx @@ -281,7 +281,7 @@ export default class Calendar extends Component { } } - containerRef: React.RefObject; + containerRef: React.RefObject; monthContainer: CalendarState["monthContainer"] = undefined; diff --git a/src/calendar_icon.tsx b/src/calendar_icon.tsx index 624ba7055..412531e1e 100644 --- a/src/calendar_icon.tsx +++ b/src/calendar_icon.tsx @@ -44,11 +44,16 @@ const CalendarIcon: React.FC = ({ if (React.isValidElement(icon)) { // Because we are checking that typeof icon is string first, we can safely cast icon as React.ReactElement on types level and code level - return React.cloneElement(icon as React.ReactElement, { - className: `${icon.props.className || ""} ${defaultClass} ${className}`, + const iconElement = icon as React.ReactElement<{ + className: string; + onClick: (event: React.MouseEvent) => void; + }>; + + return React.cloneElement(iconElement, { + className: `${iconElement.props.className || ""} ${defaultClass} ${className}`, onClick: (event: React.MouseEvent) => { - if (typeof icon.props.onClick === "function") { - icon.props.onClick(event); + if (typeof iconElement.props.onClick === "function") { + iconElement.props.onClick(event); } if (typeof onClick === "function") { diff --git a/src/input_time.tsx b/src/input_time.tsx index 67229cd3c..bd0d8c227 100644 --- a/src/input_time.tsx +++ b/src/input_time.tsx @@ -5,7 +5,11 @@ interface InputTimeProps { date?: Date; timeString?: string; timeInputLabel?: string; - customTimeInput?: React.ReactElement; + customTimeInput?: React.ReactElement<{ + date?: Date; + value: string; + onChange: (time: string) => void; + }>; } interface InputTimeState { @@ -32,7 +36,7 @@ export default class InputTime extends Component< InputTimeProps, InputTimeState > { - inputRef: React.RefObject = React.createRef(); + inputRef: React.RefObject = React.createRef(); constructor(props: InputTimeProps) { super(props); diff --git a/src/tab_loop.tsx b/src/tab_loop.tsx index 3695b1117..a830e25ef 100644 --- a/src/tab_loop.tsx +++ b/src/tab_loop.tsx @@ -54,7 +54,7 @@ export default class TabLoop extends Component { this.tabLoopRef = createRef(); } - private tabLoopRef: React.RefObject; + private tabLoopRef: React.RefObject; /** * `getTabChildren` is a method of the `TabLoop` class that retrieves all tabbable children of the component. diff --git a/src/with_floating.tsx b/src/with_floating.tsx index 8efed00b2..7635cc664 100644 --- a/src/with_floating.tsx +++ b/src/with_floating.tsx @@ -48,7 +48,7 @@ export default function withFloating( const WithFloating: React.FC = (props): React.ReactElement => { const hidePopper: boolean = typeof props.hidePopper === "boolean" ? props.hidePopper : true; - const arrowRef: React.RefObject = useRef(null); + const arrowRef: React.RefObject = useRef(null); const floatingProps = useFloating({ open: !hidePopper, whileElementsMounted: autoUpdate, diff --git a/src/year_dropdown_options.tsx b/src/year_dropdown_options.tsx index cf0c7cc98..fcd991850 100644 --- a/src/year_dropdown_options.tsx +++ b/src/year_dropdown_options.tsx @@ -87,7 +87,7 @@ export default class YearDropdownOptions extends Component< } } - dropdownRef: React.RefObject; + dropdownRef: React.RefObject; renderOptions = (): React.ReactElement[] => { const selectedYear = this.props.year;