Material-ui-pickers: Import declaration conflicts in TypeScript 3.7

Created on 1 Nov 2019  路  9Comments  路  Source: mui-org/material-ui-pickers

In TypeScript 3.7, a breaking change is introduced affecting local and imported type declarations:

https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-rc/#local-and-imported-type-declarations-now-conflict

This breaks type declarations like this one (https://github.com/mui-org/material-ui-pickers/blob/v3.2.7/lib/src/index.ts):

import { MaterialUiPickersDate } from './typings/date';

export type MaterialUiPickersDate = MaterialUiPickersDate;

Error:

Import declaration conflicts with local declaration of 'MaterialUiPickersDate'

The solution is to simply re-export the type:

export  { MaterialUiPickersDate } from './typings/date';

Environment

| Tech | Version |
| -------------------- | ------- |
| typescript | 3.7.1-rc |
| @material-ui/pickers | 3.2.7 |
| material-ui | 4.5.2 |
| React | 16.11.0 |
| Browser | Chrome |
| Peer library | [email protected] | |

Steps to reproduce

  1. Install [email protected]
  2. Try to compile the code or lint it with ts-lint.

Expected behavior

Code compiles OK.

Actual behavior

Error:

Import declaration conflicts with local declaration of 'MaterialUiPickersDate'

Most helpful comment

Found a workaround. Importing from @material-ui/pickers/DatePicker/DatePicker instead of @material-ui/pickers/DatePicker avoids this issue.

All 9 comments

I confirm the issue with 3.7.2

Has anyone got any ideas of a workaround for this problem in the meantime? We'd really like to upgrade to TS 3.7 asap.

Found a workaround. Importing from @material-ui/pickers/DatePicker/DatePicker instead of @material-ui/pickers/DatePicker avoids this issue.

Found a workaround. Importing from @material-ui/pickers/DatePicker/DatePicker instead of @material-ui/pickers/DatePicker avoids this issue.

@mvestergaard That seems to do it, thanks for the workaround!

@mvestergaard that worked for me, too. Thanks!

WIP

node_modules/@material-ui/core/Portal/Portal.d.ts:2:10 - error TS2440: Import declaration conflicts with local declaration of 'PortalProps'.

2 import { PortalProps } from '../Portal';
getting a error in this.

@deeptikanta Do you have a reproduction with v4.0.0-alpha.5?

@oliviertassinari no

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sakulstra picture sakulstra  路  3Comments

basselAhmed picture basselAhmed  路  3Comments

mnemanja picture mnemanja  路  3Comments

Lysander picture Lysander  路  3Comments

killjoy2013 picture killjoy2013  路  3Comments