Encountering similar issues during the transition from Angular 6.x to 8.x (TypeScript 3.5+), specifically with conflicting @types/jasmine type-files (index.d.ts & 3.1/index.d.ts), I resolved the problem in the following manner:
Summary of Solution
- Deleted @types/jasmine from package.json and incorporated its 3.1/index.d.ts as a static file within my source code.
- Removed @types/jasminewd2 from package.json and included it as a static file since it references @types/jasmine.
- Adjusted certain configuration files to acknowledge the presence of the static-type-files.
- Reinstalled libraries
Detailed Steps
1. Removal:
Eliminated entries from package.json
"devDependencies": {
...
"@types/jasmine": "3.4.0",
"@types/jasminewd2": "2.0.6",
...
}
2. Addition:
Added folders & files to the 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. Configuration Changes:
tsconfig.json (replace XXX with your folder structure)
...
"typeRoots": [
...
"src/ XXX /@types"
]
...
tsconfig.spec.json
...
"types": [
...
"jasminewd2"
]
...
4. Library Reinstallation
Execute npm install
If Conflicts Resurface
- Reverse the above steps
- Reinstall packages using
npm install @types/jasmine --save-dev
npm install @types/jasminewd2 --save-dev
Additional Insight
Given that only a few related complaints were found online, it is conceivable that the provided solution is temporary, suggesting there might be a more optimal fix for this issue. It's possible that an unresolved error within the Angular project's configuration is causing a dilemma where choosing between "using TypeScript below 3.1" or "using TypeScript from 3.1 onwards" is not feasible 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