arqex / arqex/react-datetime

`currentView` missing from `DatetimepickerState` in TS `typings/DateTime.d.ts`

Open
#826 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

### I'm Submitting a ...

```
[x] Bug report
[ ] Feature request
[ ] Support request
```

I am currently using the TypeScript types from the Datetime component and noticed when I try to access the state.currentView I get this TS error `Argument of type '{ currentView: string; }' is not assignable to parameter of type 'DatetimepickerState | ((prevState: Readonly, props: Readonly) => DatetimepickerState | ... 1 more ... | null) | Pick<...> | null'.`

Looking at the code looks like you have
```
this.state = {
open: !props.input,
currentView: props.initialViewMode || this.getInitialView(),
viewDate: this.getInitialViewDate(selectedDate),
selectedDate:
selectedDate && selectedDate.isValid() ? selectedDate : undefined,
inputValue: this.getInitialInputValue(selectedDate),
};
```

And in DateTime.d.ts you have
```
export interface DatetimepickerState {
updateOn: string;
inputFormat: string;
viewDate: Moment;
selectedDate: Moment;
inputValue: string;
open: boolean;
}
```

Shouldn't `DatetimepickerState` include `currentView: ViewMode` in the interface and it seems like you can remove `updateOn: string;`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.