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

DateRangeInput onChange's signature inaccurate #3470

Closed
matthieu-beteille opened this issue Apr 9, 2019 · 1 comment
Closed

DateRangeInput onChange's signature inaccurate #3470

matthieu-beteille opened this issue Apr 9, 2019 · 1 comment

Comments

@matthieu-beteille
Copy link

matthieu-beteille commented Apr 9, 2019

The DateRangeInput can call its onChange handler will null values in the range (as mentioned in the following comment):

/**
* Called when the user selects a day.
* If no days are selected, it will pass `[null, null]`.
* If a start date is selected but not an end date, it will pass `[selectedDate, null]`.
* If both a start and end date are selected, it will pass `[startDate, endDate]`.
*/
onChange?: (selectedRange: DateRange) => void;
/**

But the DateRange type doesn't include null in its signature:

export type DateRange = [Date | undefined, Date | undefined];

It seems like throughout your codebase you use double equals to check for null/undefined values (value == null) so you wouldn't run into this issue.

But on stricter codebases which want to be more explicit, if we follow the types we would only check for === undefined when the value could also potentially be null.

@adidahiya
Copy link
Contributor

adidahiya commented Apr 9, 2019

This is true across virtually all of blueprint's type definitions because we don't use the strictNullChecks compiler option. Everything is potentially null. We'd like to enable this option, but it's a large change to make across the codebase. We'll get to it someday...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants