Material-ui-pickers: Typescript compilation error in KeyboardDatePicker

Created on 30 Apr 2019  路  8Comments  路  Source: mui-org/material-ui-pickers

image

Environment

| Tech | Version |
|---------------------|---------|
| material-ui-pickers | 3.0.0-alpha.3 |
| material-ui | 4.0.0-beta.0 |
| React | 16.8.2 |
| Browser | Chrome |
| Typescript | 3.3.3333 |
| Peer library | moment 2.24.0 |

Steps to reproduce

  1. Import latest versions of the above
  2. Include a KeyboardDateInput component
  3. Try to compile (or view in VSCode with TS checking)

Expected behavior

Compiles / no TS errors

Actual behavior

TS errors with:

Type '{ format: string; id: string; label: Element; onChange: (date: Moment) => void; value: string; }' is missing the following properties from type 'Pick<KeyboardDatePickerProps, "open" | "onAccept" | "okLabel" | "cancelLabel" | "clearLabel" | "todayLabel" | "showTodayButton" | "clearable" | "DialogProps" | "children" | ... 312 more ... | "invalidDateMessage">': onAuxClick, onAuxClickCapturets(2739)

Live example

Alas I'm not sure how to make a live demo with a typescript error

incomplete typescript

Most helpful comment

Upgrading from @types/[email protected] to @types/[email protected] solves the problem for me too.

All 8 comments

My code for reference

<KeyboardDatePicker
        format={getLocalDateFormat()}
        label={<FormattedMessage id="reports.endDate" />}
        onChange={(date: Moment) => dateToUpdate(date)}
        value={toDate}
      />

Please checkout this sandbox https://codesandbox.io/s/74wj801koj
Everything works fine without any ts errors. Moreover it is not needed anymore to strictly type (date: Moment) => dateToUpdate()). It will automatically infer the type

I suppose the error coming from version conflict with material-ui or react

Have the same issue and have same versions

I suppose you have outdated @types/react

@dmtrKovalenko I will update my React types and test

Ok, with @types/[email protected] I seem to have cleared that error

Upgrading from @types/[email protected] to @types/[email protected] solves the problem for me too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danmce picture danmce  路  3Comments

basselAhmed picture basselAhmed  路  3Comments

Lysander picture Lysander  路  3Comments

sakulstra picture sakulstra  路  3Comments

mnemanja picture mnemanja  路  3Comments