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

Docs for DateRange show the wrong type (null should be undefined) #3838

Closed
elilambnz opened this issue Nov 12, 2019 · 3 comments · Fixed by #3983
Closed

Docs for DateRange show the wrong type (null should be undefined) #3838

elilambnz opened this issue Nov 12, 2019 · 3 comments · Fixed by #3983

Comments

@elilambnz
Copy link

Environment

  • Package version(s): @blueprintjs/datetime 3.9.2
  • Browser and OS versions: N/A

If possible, link to a minimal repro (fork this code sandbox): https://codesandbox.io/s/blueprint-sandbox-wrskg

Type 'null[]' is missing the following properties from type '[Date | undefined, Date | undefined]': 0, 1ts(2739)
dateRangePicker.d.ts(75, 5): The expected type comes from property 'value' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<DateRangePicker> & Pick<Readonly<IDateRangePickerProps> & Readonly<{ children?: ReactNode; }>, "children"> & Partial<Pick<...>> & Partial<...>'
@adidahiya
Copy link
Contributor

adidahiya commented Nov 12, 2019

The error message tells you which types are supported; you may use undefined, but not null. Is there a particular reason you need to use null for the start and end?

@elilambnz
Copy link
Author

There's no particular reason I need to use null, this is simply a result of following the documentation of the DateRangePicker component. It's also used in the code example.

After a quick look at the source code, I initially thought that if I changed it to undefined that it would break the non-null checks. But of course != null is still falsey for undefined. Thanks JavaScript!

Nonetheless, this still causes type errors if following exactly how the documentation does it.

@adidahiya
Copy link
Contributor

Hmm sorry about that, it looks like the documentation at https://blueprintjs.com/docs/#datetime/daterangepicker.date-ranges is wrong... it should use undefined instead of null. Should be an easy PR to fix this!

As for the code example... null is actually used in the component state of DateRangePickerExample, but it is never sent to DateRangePicker itself since the example uses the component in an "uncontrolled" manner... yeah I understand that's a bit confusing, perhaps it's worth a small refactor.

@adidahiya adidahiya changed the title DateRangePicker value prop has incorrect types Docs for DateRange show the wrong type (null should be undefined) Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants