material-ui-pickers icon indicating copy to clipboard operation
material-ui-pickers copied to clipboard

Import declaration conflicts in TypeScript 3.7

Open mfellner opened this issue 7 years ago • 9 comments

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'

mfellner avatar Nov 01 '19 15:11 mfellner

I confirm the issue with 3.7.2

LoicMahieu avatar Nov 05 '19 16:11 LoicMahieu

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.

mvestergaard avatar Nov 06 '19 11:11 mvestergaard

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

mvestergaard avatar Nov 06 '19 12:11 mvestergaard

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!

gaelollivier avatar Nov 06 '19 17:11 gaelollivier

@mvestergaard that worked for me, too. Thanks!

blitzard7 avatar Nov 07 '19 08:11 blitzard7

WIP

dmtrKovalenko avatar Nov 13 '19 11:11 dmtrKovalenko

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 avatar May 06 '20 11:05 deeptikanta

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

oliviertassinari avatar May 06 '20 11:05 oliviertassinari

@oliviertassinari no

deeptikanta avatar May 06 '20 11:05 deeptikanta