date-io icon indicating copy to clipboard operation
date-io copied to clipboard

Proper fix for using both date-fns and luxon in same project

Open fatso83 opened this issue 4 years ago • 1 comments

I inherited a TypeScript project that has not been compiling in a long time, it seems. One error deals with it having both date-fns and luxon in the same project, along with corresponding types, that seem to crash.

node_modules/@date-io/date-fns/type/index.d.ts:2:15 - error TS2300: Duplicate identifier 'DateType'.

2   export type DateType = Date;
                ~~~~~~~~

  node_modules/@date-io/luxon/type/index.d.ts:4:15
    4   export type DateType = DateTime;
                    ~~~~~~~~
    'DateType' was also declared here.

node_modules/@date-io/luxon/type/index.d.ts:4:15 - error TS2300: Duplicate identifier 'DateType'.

4   export type DateType = DateTime;
                ~~~~~~~~

  node_modules/@date-io/date-fns/type/index.d.ts:2:15
    2   export type DateType = Date;
                    ~~~~~~~~
    'DateType' was also declared here.

Aside from the fact that these two libraries are overlapping in functionality (and I should probably refactor to just have one), what is the proper fix here? My quick fix was simply to remove one of the offending files in node_modules, but that's hardly a proper solution ... (although it does the job when paired with patch-package)

fatso83 avatar Aug 16 '21 09:08 fatso83

It's a problem – we are not using this ephimeral type anymore and there is a PR #416 to remove support but it will require major upgrade which is hard to adopt

dmtrKovalenko avatar Aug 16 '21 10:08 dmtrKovalenko