Skip to content

Commit b34bfb2

Browse files
committed
chore: remove non-null assertions
1 parent c4323b3 commit b34bfb2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/index.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,12 @@ export default class DatePicker extends Component<
586586
lastPreSelectChange: PRESELECT_CHANGE_VIA_INPUT,
587587
});
588588

589-
const { dateFormat, strictParsing, selectsRange, startDate, endDate } =
590-
this.props;
589+
const { selectsRange, startDate, endDate } = this.props;
590+
591+
const dateFormat =
592+
this.props.dateFormat ?? DatePicker.defaultProps.dateFormat;
593+
const strictParsing =
594+
this.props.strictParsing ?? DatePicker.defaultProps.strictParsing;
591595

592596
const value =
593597
event?.target instanceof HTMLInputElement ? event.target.value : "";
@@ -598,15 +602,15 @@ export default class DatePicker extends Component<
598602
.map((val) => val.trim());
599603
const startDateNew = parseDate(
600604
valueStart ?? "",
601-
dateFormat!,
605+
dateFormat,
602606
this.props.locale,
603-
strictParsing!,
607+
strictParsing,
604608
);
605609
const endDateNew = parseDate(
606610
valueEnd ?? "",
607-
dateFormat!,
611+
dateFormat,
608612
this.props.locale,
609-
strictParsing!,
613+
strictParsing,
610614
);
611615
const startChanged = startDate?.getTime() !== startDateNew?.getTime();
612616
const endChanged = endDate?.getTime() !== endDateNew?.getTime();
@@ -627,9 +631,9 @@ export default class DatePicker extends Component<
627631
// not selectsRange
628632
const date = parseDate(
629633
value,
630-
dateFormat!,
634+
dateFormat,
631635
this.props.locale,
632-
strictParsing!,
636+
strictParsing,
633637
this.props.selected ?? undefined,
634638
);
635639

0 commit comments

Comments
 (0)