error TS6200: Definitions of the following identifiers conflict with those in another file (@types/jasmine)
Solution 1
Just answered the same question here: Definitions of identifiers conflict with those in another file
Posting it again.
Check types
subsection in your tsconfig.spec.json
, most probably it has something like that
"types": [
"jasmine",
"node"
]
I removed jasmine
so my types
section looks like that:
"types": [
"node"
]
and it helped.
Solution 2
Having had the same problems when migrating from Angular 6.x to 8.x (typescript 3.5+) with both @types/jasmine type-files (index.d.ts & 3.1/index.d.ts) competing with each other i solved it the following way:
Quick overview
- Removed @types/jasmine from package.json and instead added its 3.1/index.d.ts as a static file within my sourcecode.
- As @types/jasminewd2 references @types/jasmine, also removed this lib from package.json and added as static file.
- Changed some config-files to recognize the static-type-files.
- Re-install libs
Steps in detail
1. Removed:
entries from package.json
"devDependencies": {
...
"@types/jasmine": "3.4.0",
"@types/jasminewd2": "2.0.6",
...
}
2. Added instead:
folders & files to file-structure below src-folder
src (folder)
...
@types
jasmine
index.d.ts (from node_modules/@types/jasmine/3.1/index.d.ts)
jasminewd2
index.d.ts (from node_modules/@types/jasminewd2/index.d.ts)
3. Changed configs:
tsconfig.json (where XXX corresponds to your folder-structure)
...
"typeRoots": [
...
"src/ XXX /@types"
]
...
tsconfig.spec.json
...
"types": [
...
"jasminewd2"
]
...
4. Re-install libs
run npm install
Once conflicts will be resumed lateron
- undo the above steps
- re-install packages with
npm install @types/jasmine --save-dev
npm install @types/jasminewd2 --save-dev
Additional background
As searching the internet showed only 2 similar complaints the assumption is close, that the above mentioned solution is a fix only, but there must be a better one (otherwise more people would complain about the problem). it might be that there is an unrecognized error somewhere within the configuration of the angular-project that could lead to a point where a decision between "we're using typescript below 3.1" and "we're using typescript from 3.1 up" isn't possible within @types/jasmine.
- error TS6200: Definitions of the following identifiers conflict with those in another file (@types/jasmine)
- Definitions of identifiers conflict with those in another file
Solution 3
If anyone is getting this error while using mangoose, types are included in mongoose by default for 5.11 so just remove the @types/mongoose
from your devDependencies and it will work fine. Refer to this.
@types/mongoose - Type Definitions conflict with those in mongoose 5.11
#49950
![mindparse](https://i.stack.imgur.com/Glsj4.png?s=256&g=1)
mindparse
Updated on June 06, 2022Comments
-
mindparse about 2 years
I am receiving the following error when attempting to build my project (using Angular CLI)
ERROR in ../my-app/node_modules/@types/jasmine/index.d.ts(18,1): error TS6200: Definitions of the following identifiers conflict with those in another file: Expected, SpyObjMethodNames, clock, CustomEqualityTester, CustomMatcherFactory, ExpectationFailed, SpecFunction, SpyObj, jasmine
I am using VSCode, and when I go to the line in question, I have the option to view the file it says its conflicting with.
This takes me to a file at the following location:
/Users/<user_name>/Library/Caches/typescript/3.3/node_modules/@types/jasmine/ts3.1/index.d.ts
I'm a little lost to understand why the TS compiler is trying to use this cached type definition, what could be going on here?
Thanks