Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. #5348

Closed

Description

@SACHINBN

Hi Sir!

Bug report
I am getting following below error :

ERROR in [at-loader] ./node_modules/protractor/built/index.d.ts:5:10
TS2440: Import declaration conflicts with local declaration of 'PluginConfig'.
 
ERROR in [at-loader] ./node_modules/protractor/built/index.d.ts:5:24
TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'.

  • Node Version: 10.5.0
  • Protractor Version: ~5.1.2
  • Angular Version: ^4.2.4
  • Browser(s): any
  • Operating System and Version Windows 10
  • Your protractor configuration file

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};

  • Steps to reproduce the bug - npm run build fail

Feature Request
Please help me to resolve

Activity

  1. josh-s-g commented on Nov 6, 2019

    @josh-s-g

    As of today I'm getting the same issue (with Protractor 5.4.2 and Angular 8)

  2. DanikRaikhlin commented on Nov 6, 2019

    @DanikRaikhlin

    Same issue here with Protractor 5.4.2 and Angular 8

  3. mattcasey commented on Nov 6, 2019

    @mattcasey

    I ran into this today while upgrading our Typescript version. We're on AngularJS and it occurs for both Protractor 5.4.1 and 5.4.2. I do not get the error on Typescript 3.6.4 (3.6.x), but I do with Typescript 3.7.2 (3.7.x). I believe it's related to this breaking change: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#local-and-imported-type-declarations-now-conflict

    Please fix; we need nullish coalescing! :)

  4. akwiatek commented on Nov 6, 2019

    @akwiatek

    Same problem here. My project is at Protractor 5.4.2 and we would like to migrate to TypeScript 3.7 .

    It would be great to backport the fix (it surely works):
    89fbf75
    37bef24
    from master to 5.4.2

    5.4.2 is the latest version available at npmjs.com .
    6.0.0 contains breaking changes, so it is not good for my project.
    ( https://github.com/angular/protractor/blob/6.0.0/CHANGELOG.md )

    CC: @sandersn @heathkit

  5. sandersn commented on Nov 6, 2019

    @sandersn
    Contributor

    Duplicate of #5325

    Edit: I should clarify that I work on the Typescript team, not the Angular team. I talked to some team members who said they would try to publish a new 5.* version, but I believe the process is not simple.

  6. SACHINBN commented on Nov 7, 2019

    @SACHINBN
    Author

    Today I have downgraded the typescript version from 3.7.x to 3.6.x.,It is working fine . Thank you mattcasey

  7. mattcasey commented on Nov 7, 2019

    @mattcasey

    Thanks for clarifying @sandersn; that was going to be my next question. We don't rely on flow control and I tried updating to 6.0.0 but even that published package doesn't seem to have your fix yet. It'd be great if someone from the team could comment here: are we talking a few days, a few months, or more?

    Edit: I'd offer to help but it seems like the hold-up is "just" in releasing a new version :)

    Edit 2: Since the rest of our system has moved on to TS 3.7, the lesser of two evils for me was to override the types from protractor for now by linking to a custom .d.ts file in our tsconfig: https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping

  8. woppa684 commented on Nov 13, 2019

    @woppa684

    @mattcasey Could you describe in a bit more detail how your current fix works? Just a copied index.d.ts file with the correct export paths and then use the path mapping to map protractor to the new file?

  9. ayoubde commented on Nov 13, 2019

    @ayoubde

    Update types/node dependency
    npm install -g @types/node@8

    Make sure that types/node is listed in both devDependencies and dependencies

    "dependencies": { ... "@types/node": "^8.10.59", ... }, "devDependencies": { ... "@types/node": "^8.10.59", ... }

  10. anicarrr commented on Nov 14, 2019

    @anicarrr

    In case this happen with any module using typescript 3.7.2 you can use the "as" statement.

    import { module as otherModuleName } from "./module"

    Or you could export the module as default so you can use a different variable name

  11. benbreaker0412 commented on Nov 24, 2019

    @benbreaker0412

    Today I have downgraded the typescript version from 3.7.x to 3.6.x.,It is working fine . Thank you mattcasey

    It put "typescript": "~3.6" to file package.json then run "npm install" on terminal and it worked for me. Thanks!

  12. VenkatSaripilli commented on Nov 24, 2019

    @VenkatSaripilli

    Same issue and when I downgraded to 3.6.4 it worked.

  13. SamuelMarks commented on Nov 26, 2019

    @SamuelMarks

    Same issue here, I had to npm uninstall -g typescript so that the local version of tsc would take priority. I could've messed with PATH instead…

  14. mattcasey commented on Nov 26, 2019

    @mattcasey

    @woppa684 my fix is essentially to create my own types for Protractor and tell Typescript to ignore the one inside of node_modules. My protractor.d.ts (located in my project at test-e2e/protractor.d.ts) file looks like this:

    // Note: This stub exists to override Protractor types which are incompatible with TS 3.7 as of 5.4.2 and 6.0.0
    declare module 'protractor' {
        let browser: any;
        let element: any;
        let by: any;
        let ExpectedConditions: any;
        let until: any;
        let Key: any;
    }
    

    And then in tsconfig:

    {
      ...
      "compilerOptions": {
        ...
        "paths": {
          "protractor": ["test-e2e/protractor.d.ts"]
        }
      }
    }
    

    This allows me to use Typescript 3.7 with the downside that protractor methods are no longer type-safe.

  15. tomyam1 commented on Dec 6, 2019

    @tomyam1

    An alternative solution we used is to create a modified build of protractor with the fixes in #5326

    We than temporarily use it instead of protractor

    // package.json
    "protractor": "tomyam1/protractor-ts3.7-fix"
  16. bluebaroncanada commented on Dec 16, 2019

    @bluebaroncanada

    I'm having this problem on devops with Angular. This just started happening. I went back and grabbed a package.json and package-lock.json from a time I know it worked.
    I upgraded Angular. I tried several different typescript versions. It works on my local computer, but not on devops. It's only the vs build portion that's failing. The npm/ng stuff runs just fine.
    Everything works completely on my system.
    https://developercommunity.visualstudio.com/content/problem/855096/npm-ng-suddenly-not-working-conflict-pluginconfig.html

  17. lucky1895 commented on Dec 19, 2019

    @lucky1895

    In case this happen with any module using typescript 3.7.2 you can use the "as" statement.

    import { module as otherModuleName } from "./module"

    Or you could export the module as default so you can use a different variable name

    @anicarrr , Could you please provide an example for second answer u provided?

  18. JonWallsten commented on Dec 23, 2019

    @JonWallsten

    May not be the best solution for everyone, but you should be able to fix this by adding the following in tsconfig.json:

    "skipLibCheck": true
    
  19. anicarrr commented on Dec 26, 2019

    @anicarrr

    In case this happen with any module using typescript 3.7.2 you can use the "as" statement.
    import { module as otherModuleName } from "./module"
    Or you could export the module as default so you can use a different variable name

    @anicarrr , Could you please provide an example for second answer u provided?

    I mean exporting like:

    export default myModule

    so then when you import it you can just use whatever name you want, like:

    import whateverName from myModule

  20. IgorMinar commented on Jan 17, 2020

    @IgorMinar

    This was fixed in #5326. We are working on getting a patch release out.

  21. IgorMinar commented on Jan 17, 2020

    @IgorMinar

    fyi: in the meantime using tsc compiler option "skipLibCheck": true should be a sufficient workaround for those affected by this issue.

  22. ameyasworld commented on Jan 21, 2020

    @ameyasworld

    Hi Sir!

    Bug report
    I am getting following below error :

    ERROR in [at-loader] ./node_modules/protractor/built/index.d.ts:5:10
    TS2440: Import declaration conflicts with local declaration of 'PluginConfig'.
     
    ERROR in [at-loader] ./node_modules/protractor/built/index.d.ts:5:24
    TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'.

    • Node Version: 10.5.0
    • Protractor Version: ~5.1.2
    • Angular Version: ^4.2.4
    • Browser(s): any
    • Operating System and Version Windows 10
    • Your protractor configuration file

    const { SpecReporter } = require('jasmine-spec-reporter');

    exports.config = {
    allScriptsTimeout: 11000,
    specs: [
    './e2e/**/*.e2e-spec.ts'
    ],
    capabilities: {
    'browserName': 'chrome'
    },
    directConnect: true,
    baseUrl: 'http://localhost:4200/',
    framework: 'jasmine',
    jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
    },
    onPrepare() {
    require('ts-node').register({
    project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    }
    };

    • Steps to reproduce the bug - npm run build fail

    Feature Request
    Please help me to resolve

    Hi SachinBN,

    You need to change version of Typescript installed in project. Use below command in VS Code terminal to change version(without quotes).

    "npm install -g typescript@3.6.2"

    Once done, please check version of typescript in your project on VS Code, using below command

    "tsc -v"

    It should show 3.6.2. Please use same version in package.json file. Once version is changed to 3.6.2 execute "tsc" again, error should be gone.

    Hope this helps.

    Regards,

    Ameya

  23. Nishit-Zinzuvadiya commented on Jan 28, 2020

    @Nishit-Zinzuvadiya

    I had this issue in my angular app and I am able to resolve it via removing the protractor import statement which is automatically added by the suggestions.

    Like:

    import { element } from 'protractor'
    import { promise } from 'protractor'

    Just remove them I will run as expected.
    Mine worked, I hope your code work too.

    Regards,
    Nishit Zinzuvadiya

  24. Serhioromano commented on Mar 30, 2020

    @Serhioromano
    npx tsc -v
    Version 3.8.3
    

    Latest node and NPM.

    My file

    import * as mysql from "mysql2";
    
    const config =
    	process.env.NODE_ENV == "prod"
    		? {
    			connectionLimit: 10,
    			host: "*********.rds.amazonaws.com",
    			user: "admin",
    			database: "p_" + process.env.PROJECT_ID,
    			password: "*********",
    			prefix: `p_${process.env.PROJECT_ID}_`
    		}
    		: {
    			connectionLimit: 10,
    			host: "host.docker.internal",
    			user: "root",
    			database: "i**_project",
    			password: "root",
    			prefix: ""
    		};
    
    
    export const db = mysql.createPool(config);
    export const prefix = config.prefix;

    And I have same error

    npm run start
    
    > icod-rt@1.0.0 start /workspaces/icod-prt
    > npx tsc && node build/index.js
    
    typings/modules/mysql2/index.d.ts:677:1 - error TS2440: Import declaration conflicts with local declaration of 'Connection'.
    
    677 import Connection = require('~mysql2~mysql/lib/Connection');
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    typings/modules/mysql2/index.d.ts:679:1 - error TS2440: Import declaration conflicts with local declaration of 'PoolConnection'.
    
    679 import PoolConnection = require('~mysql2~mysql/lib/PoolConnection');
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    typings/modules/mysql2/index.d.ts:680:1 - error TS2440: Import declaration conflicts with local declaration of 'Pool'.
    
    680 import Pool = require('~mysql2~mysql/lib/Pool');
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    typings/modules/mysql2/index.d.ts:682:1 - error TS2440: Import declaration conflicts with local declaration of 'PoolCluster'.
    
    682 import PoolCluster = require('~mysql2~mysql/lib/PoolCluster');
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    typings/modules/mysql2/index.d.ts:684:1 - error TS2440: Import declaration conflicts with local declaration of 'Query'.
    
    684 import Query = require('~mysql2~mysql/lib/protocol/sequences/Query');
    
  25. antman2 commented on Aug 25, 2020

    @antman2

    Sometimes the TypeScript compiler just blames errors on someone else's smoking gun.

    I got the OP's exact error message today while working on .spec.ts unit test files. Since I didn't need Protractor for unit tests I temporarily uninstalled it with npm uninstall protractor which then caused TypeScript to throw the real error:

    ERROR in src/app/.../...spec.ts:12:30 - error TS2307: Cannot find module 'protractor'.
    12 import { EventEmitter } from 'protractor';
    

    The cause was Visual Studio Code had inexplicably created this automatic import statement instead of the normal one, import { EventEmitter } from '@angular/core';

  26. nikita-fuchs commented on Sep 10, 2020

    @nikita-fuchs

    I had this issue in my angular app and I am able to resolve it via removing the protractor import statement which is automatically added by the suggestions.

    Like:

    import { element } from 'protractor'
    import { promise } from 'protractor'

    Just remove them I will run as expected.
    Mine worked, I hope your code work too.

    Regards,
    Nishit Zinzuvadiya

    For me it was VSCode's auto-import, that imported EventEmitter from Protractor instead of @angular/core. Fixing this fixed the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions