-
Notifications
You must be signed in to change notification settings - Fork 2.3k
TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. #5348
Comments
As of today I'm getting the same issue (with Protractor 5.4.2 and Angular 8) |
Same issue here with Protractor 5.4.2 and Angular 8 |
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! :) |
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): 5.4.2 is the latest version available at npmjs.com . |
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. |
Today I have downgraded the typescript version from 3.7.x to 3.6.x.,It is working fine . Thank you 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 |
@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? |
Update types/node dependency Make sure that types/node is listed in both devDependencies and dependencies
|
In case this happen with any module using typescript 3.7.2 you can use the "as" statement.
Or you could export the module as default so you can use a different variable name |
It put "typescript": "~3.6" to file package.json then run "npm install" on terminal and it worked for me. Thanks! |
Same issue and when I downgraded to 3.6.4 it worked. |
Same issue here, I had to |
@woppa684 my fix is essentially to create my own types for Protractor and tell Typescript to ignore the one inside of node_modules. My
And then in tsconfig:
This allows me to use Typescript 3.7 with the downside that protractor methods are no longer type-safe. |
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" |
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. |
@anicarrr , Could you please provide an example for second answer u provided? |
May not be the best solution for everyone, but you should be able to fix this by adding the following in tsconfig.json:
|
I mean exporting like:
so then when you import it you can just use whatever name you want, like:
|
With TS 3.7, these examples were running into the error below (e.g. on https://circleci.com/gh/angular/angular/574906#tests/containers/0): ``` ============== AIO example output for: /home/circleci/ng/aio/content/examples/observables/ running: yarn tsc --project ./ $ /home/circleci/ng/aio/content/examples/observables/node_modules/.bin/tsc --project ./ ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,24): error TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. completed: yarn tsc --project ./ ``` This happened because of angular/protractor#5348. It's unclear why this typings problem does not affect `ng e2e` runs, and only affects `tsc` runs. For now it seems sensible to alter the tests to compile only the app and not the e2e, since the intent of angular@2cc954d was never to verify the correctness of the e2e in the first place. We still need a release of protractor that supports TS 3.7 though, but at least it doesn't seem to block our update proper.
With TS 3.7, these examples were running into the error below (e.g. on https://circleci.com/gh/angular/angular/574906#tests/containers/0): ``` ============== AIO example output for: /home/circleci/ng/aio/content/examples/observables/ running: yarn tsc --project ./ $ /home/circleci/ng/aio/content/examples/observables/node_modules/.bin/tsc --project ./ ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,24): error TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. completed: yarn tsc --project ./ ``` This happened because of angular/protractor#5348. It's unclear why this typings problem does not affect `ng e2e` runs, and only affects `tsc` runs. For now it seems sensible to alter the tests to compile only the app and not the e2e, since the intent of angular@2cc954d was never to verify the correctness of the e2e in the first place. We still need a release of protractor that supports TS 3.7 though, but at least it doesn't seem to block our update proper.
With TS 3.7, these examples were running into the error below (e.g. on https://circleci.com/gh/angular/angular/574906#tests/containers/0): ``` ============== AIO example output for: /home/circleci/ng/aio/content/examples/observables/ running: yarn tsc --project ./ $ /home/circleci/ng/aio/content/examples/observables/node_modules/.bin/tsc --project ./ ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,24): error TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. completed: yarn tsc --project ./ ``` This happened because of angular/protractor#5348. It's unclear why this typings problem does not affect `ng e2e` runs, and only affects `tsc` runs. For now it seems sensible to alter the tests to compile only the app and not the e2e, since the intent of angular@2cc954d was never to verify the correctness of the e2e in the first place. We still need a release of protractor that supports TS 3.7 though, but at least it doesn't seem to block our update proper.
With TS 3.7, these examples were running into the error below (e.g. on https://circleci.com/gh/angular/angular/574906#tests/containers/0): ``` ============== AIO example output for: /home/circleci/ng/aio/content/examples/observables/ running: yarn tsc --project ./ $ /home/circleci/ng/aio/content/examples/observables/node_modules/.bin/tsc --project ./ ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,24): error TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. completed: yarn tsc --project ./ ``` This happened because of angular/protractor#5348. It's unclear why this typings problem does not affect `ng e2e` runs, and only affects `tsc` runs. For now it seems sensible to alter the tests to compile only the app and not the e2e, since the intent of angular@2cc954d was never to verify the correctness of the e2e in the first place. We still need a release of protractor that supports TS 3.7 though, but at least it doesn't seem to block our update proper.
With TS 3.7, these examples were running into the error below (e.g. on https://circleci.com/gh/angular/angular/574906#tests/containers/0): ``` ============== AIO example output for: /home/circleci/ng/aio/content/examples/observables/ running: yarn tsc --project ./ $ /home/circleci/ng/aio/content/examples/observables/node_modules/.bin/tsc --project ./ ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,24): error TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. completed: yarn tsc --project ./ ``` This happened because of angular/protractor#5348. It's unclear why this typings problem does not affect `ng e2e` runs, and only affects `tsc` runs. For now it seems sensible to alter the tests to compile only the app and not the e2e, since the intent of 2cc954d was never to verify the correctness of the e2e in the first place. We still need a release of protractor that supports TS 3.7 though, but at least it doesn't seem to block our update proper. PR Close #33717
With TS 3.7, these examples were running into the error below (e.g. on https://circleci.com/gh/angular/angular/574906#tests/containers/0): ``` ============== AIO example output for: /home/circleci/ng/aio/content/examples/observables/ running: yarn tsc --project ./ $ /home/circleci/ng/aio/content/examples/observables/node_modules/.bin/tsc --project ./ ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'PluginConfig'. ../../../tools/examples/shared/node_modules/protractor/built/index.d.ts(5,24): error TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. completed: yarn tsc --project ./ ``` This happened because of angular/protractor#5348. It's unclear why this typings problem does not affect `ng e2e` runs, and only affects `tsc` runs. For now it seems sensible to alter the tests to compile only the app and not the e2e, since the intent of 2cc954d was never to verify the correctness of the e2e in the first place. We still need a release of protractor that supports TS 3.7 though, but at least it doesn't seem to block our update proper. PR Close #33717
This was fixed in #5326. We are working on getting a patch release out. |
fyi: in the meantime using tsc compiler option |
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 [email protected]" 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 |
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' Just remove them I will run as expected. Regards, |
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
|
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
The cause was Visual Studio Code had inexplicably created this automatic import statement instead of the normal one, |
still got this in 4.0.2.. hmmm |
For me it was VSCode's auto-import, that imported |
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'.
10.5.0
~5.1.2
^4.2.4
any
Windows 10
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 } }));
}
};
Feature Request
Please help me to resolve
The text was updated successfully, but these errors were encountered: