tsc type definition conflicts, duplicate identifiers in @types/mocha chai etc
See original GitHub issueProject is https://github.com/ericblade/quagga2
Project has it’s own dependency on @types/mocha
@types/chai
declared. This is so editor support for typescript works correctly.
Running tsc
on the project in the build step fails with duplicate definitions.
On top of that, since this is also causing typescript compilation to fail, when I run ‘cypress run’, which uses webpack-preprocessor
to package, cypress just hangs indefinitely, when I would expect it to fail.
Running cypress open
does not fail, as for speed reasons, I have configured open to not use webpack-preprocessor
.
Reverting to 4.5.0 corrects the issues, and all tests run as normal.
Version of webpack-preprocessor
doesn’t seem relevant – I tried both 5.2.1 which is what I used prior to the 4.6.0 upgrade, and 5.4.1, which was the recommended upgrade with cypress 4.6.0.
> @ericblade/quagga2@1.0.5 check-types D:\src\quaggajs
> tsc
node_modules/@types/chai/index.d.ts:19:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: Message, ObjectProperty, ChaiPlugin, AssertionArgs, Operator, OperatorComparable, AssertionError, chai
19 declare namespace Chai {
~~~~~~~
node_modules/cypress/types/chai/index.d.ts:19:1
19 declare namespace Chai {
~~~~~~~
Conflicts are in this file.
node_modules/@types/mocha/index.d.ts:17:15 - error TS2300: Duplicate identifier 'Mocha'.
17 declare class Mocha {
~~~~~
node_modules/cypress/types/mocha/index.d.ts:17:15
17 declare class Mocha {
~~~~~
'Mocha' was also declared here.
node_modules/cypress/types/mocha/index.d.ts:242:19
242 declare namespace Mocha {
~~~~~
and here.
node_modules/cypress/types/mocha/index.d.ts:2856:14
2856 export = Mocha;
~~~~~
and here.
node_modules/@types/mocha/index.d.ts:242:19 - error TS2300: Duplicate identifier 'Mocha'.
242 declare namespace Mocha {
~~~~~
node_modules/cypress/types/mocha/index.d.ts:17:15
17 declare class Mocha {
~~~~~
'Mocha' was also declared here.
node_modules/cypress/types/mocha/index.d.ts:242:19
242 declare namespace Mocha {
~~~~~
and here.
node_modules/cypress/types/mocha/index.d.ts:2856:14
2856 export = Mocha;
~~~~~
and here.
node_modules/@types/mocha/index.d.ts:2814:15 - error TS2451: Cannot redeclare block-scoped variable 'mocha'.
2814 declare const mocha: BrowserMocha;
~~~~~
node_modules/cypress/types/mocha/index.d.ts:2814:15
2814 declare const mocha: BrowserMocha;
~~~~~
'mocha' was also declared here.
node_modules/@types/mocha/index.d.ts:2848:6 - error TS2300: Duplicate identifier 'MochaDone'.
2848 type MochaDone = Mocha.Done;
~~~~~~~~~
node_modules/cypress/types/mocha/index.d.ts:2848:6
2848 type MochaDone = Mocha.Done;
~~~~~~~~~
'MochaDone' was also declared here.
node_modules/@types/mocha/index.d.ts:2851:6 - error TS2300: Duplicate identifier 'ReporterConstructor'.
2851 type ReporterConstructor = Mocha.ReporterConstructor;
~~~~~~~~~~~~~~~~~~~
node_modules/cypress/types/mocha/index.d.ts:2851:6
2851 type ReporterConstructor = Mocha.ReporterConstructor;
~~~~~~~~~~~~~~~~~~~
'ReporterConstructor' was also declared here.
node_modules/@types/mocha/index.d.ts:2856:14 - error TS2300: Duplicate identifier 'Mocha'.
2856 export = Mocha;
~~~~~
node_modules/cypress/types/mocha/index.d.ts:17:15
17 declare class Mocha {
~~~~~
'Mocha' was also declared here.
node_modules/cypress/types/mocha/index.d.ts:242:19
242 declare namespace Mocha {
~~~~~
and here.
node_modules/cypress/types/mocha/index.d.ts:2856:14
2856 export = Mocha;
~~~~~
and here.
node_modules/@types/mocha/index.d.ts:2860:14 - error TS2300: Duplicate identifier 'milliseconds'.
2860 export = milliseconds;
~~~~~~~~~~~~
node_modules/cypress/types/mocha/index.d.ts:2860:14
2860 export = milliseconds;
~~~~~~~~~~~~
'milliseconds' was also declared here.
node_modules/@types/mocha/index.d.ts:2879:14 - error TS2300: Duplicate identifier 'common'.
2879 export = common;
~~~~~~
node_modules/cypress/types/mocha/index.d.ts:2879:14
2879 export = common;
~~~~~~
'common' was also declared here.
node_modules/cypress/types/chai/index.d.ts:19:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: Message, ObjectProperty, ChaiPlugin, AssertionArgs, Operator, OperatorComparable, AssertionError, chai
19 declare namespace Chai {
~~~~~~~
node_modules/@types/chai/index.d.ts:19:1
19 declare namespace Chai {
~~~~~~~
Conflicts are in this file.
node_modules/cypress/types/mocha/index.d.ts:17:15 - error TS2300: Duplicate identifier 'Mocha'.
17 declare class Mocha {
~~~~~
node_modules/@types/mocha/index.d.ts:17:15
17 declare class Mocha {
~~~~~
'Mocha' was also declared here.
node_modules/@types/mocha/index.d.ts:242:19
242 declare namespace Mocha {
~~~~~
and here.
node_modules/@types/mocha/index.d.ts:2856:14
2856 export = Mocha;
~~~~~
and here.
node_modules/cypress/types/mocha/index.d.ts:242:19 - error TS2300: Duplicate identifier 'Mocha'.
242 declare namespace Mocha {
~~~~~
node_modules/@types/mocha/index.d.ts:17:15
17 declare class Mocha {
~~~~~
'Mocha' was also declared here.
node_modules/@types/mocha/index.d.ts:242:19
242 declare namespace Mocha {
~~~~~
and here.
node_modules/@types/mocha/index.d.ts:2856:14
2856 export = Mocha;
~~~~~
and here.
node_modules/cypress/types/mocha/index.d.ts:2814:15 - error TS2451: Cannot redeclare block-scoped variable 'mocha'.
2814 declare const mocha: BrowserMocha;
~~~~~
node_modules/@types/mocha/index.d.ts:2814:15
2814 declare const mocha: BrowserMocha;
~~~~~
'mocha' was also declared here.
node_modules/cypress/types/mocha/index.d.ts:2848:6 - error TS2300: Duplicate identifier 'MochaDone'.
2848 type MochaDone = Mocha.Done;
~~~~~~~~~
node_modules/@types/mocha/index.d.ts:2848:6
2848 type MochaDone = Mocha.Done;
~~~~~~~~~
'MochaDone' was also declared here.
node_modules/cypress/types/mocha/index.d.ts:2851:6 - error TS2300: Duplicate identifier 'ReporterConstructor'.
2851 type ReporterConstructor = Mocha.ReporterConstructor;
~~~~~~~~~~~~~~~~~~~
node_modules/@types/mocha/index.d.ts:2851:6
2851 type ReporterConstructor = Mocha.ReporterConstructor;
~~~~~~~~~~~~~~~~~~~
'ReporterConstructor' was also declared here.
node_modules/cypress/types/mocha/index.d.ts:2856:14 - error TS2300: Duplicate identifier 'Mocha'.
2856 export = Mocha;
~~~~~
node_modules/@types/mocha/index.d.ts:17:15
17 declare class Mocha {
~~~~~
'Mocha' was also declared here.
node_modules/@types/mocha/index.d.ts:242:19
242 declare namespace Mocha {
~~~~~
and here.
node_modules/@types/mocha/index.d.ts:2856:14
2856 export = Mocha;
~~~~~
and here.
node_modules/cypress/types/mocha/index.d.ts:2860:14 - error TS2300: Duplicate identifier 'milliseconds'.
2860 export = milliseconds;
~~~~~~~~~~~~
node_modules/@types/mocha/index.d.ts:2860:14
2860 export = milliseconds;
~~~~~~~~~~~~
'milliseconds' was also declared here.
node_modules/cypress/types/mocha/index.d.ts:2879:14 - error TS2300: Duplicate identifier 'common'.
2879 export = common;
~~~~~~
node_modules/@types/mocha/index.d.ts:2879:14
2879 export = common;
~~~~~~
'common' was also declared here.
Found 18 errors.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:24 (4 by maintainers)
Top GitHub Comments
See this message for specifics https://github.com/cypress-io/cypress/issues/7435#issuecomment-631695007
My workaround for chai-subset is to uninstall
@types/chai-subset
(which depends on@types/chai
), and to instead place a modified version of the chai-subset type definitions in my project. I put this file incypress/types/chai-subset.d.ts
:I’m not sure it’s really necessary for
@types/chai-subset
to depend on@types/chai
. If it didn’t have that dependency, and did not include this line then I think that would solve the problem for me.