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

Open
#826 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start in typings/DateTime.d.ts and compare DatetimepickerState with the component state initializer shown in the issue. Check the ViewMode declaration and the existing state fields, then verify that the TypeScript state update accepts currentView and that the declared shape matches the implementation.

Written by the indexing model from the issue text.

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<DatetimepickerState>, props: Readonly<DatetimepickerProps>) => 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;?

Dominant language
JavaScript
Stars
2k
Forks
858
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from arqex/react-datetime

All issues in arqex/react-datetime

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.