@types/jest index.d.ts file returning error
Try adding "skipLibCheck": true
to tsconfig.json
to skip type checking of all declaration (.d.ts) files.
EDIT: This is more of a "sledgehammer" workaround than an actual fix. As referenced in the other answer, this issue probably happens because the Jest typings were made for a newer TypeScript version than the one being used in the project. So the proper fix would be upgrading the project to a newer TS version.
I hope this is not too late and might be helpful to someone.
Instead of skipping all library checks, you can override the libraries you want. In our case that would be:@types/jest
As an alternative to setting"skipLibCheck": true
to tsconfig.json
you can create a new folder and file from your root:overrides/jest/index.d.ts
and add
"compilerOptions": { "typeRoots": [ "overrides", "./node_modules/@types" ]}
This would essentially override all the types check under the overrides
folder and fallback to ./node_modules/@types
except jest thanks to overrides/jest/index.d.ts
file which can be empty.
I found this answer onhttps://medium.com/@elenasufieva/handling-type-declarations-clash-in-typescript-b05b10723f47