So I have a monorepo project, 2x parts of my project (frontend and backend) which have a root package to use both together. These use yarn workspaces to do so and pull the majority of my node_modules to the root layer including my @types files for both frontend and backend. My backend is nestjs/jest and my frontend is angular/jasmine. My frontend is still running and compiling perfectly, my backend will run fine but upon building shows 27-30 error messages about how there are conflicts in file definitions in both the @types/jest and @types/jasmine files. I'm unsure as to why the frontend doesn't pick up on this but the backend does and how I can resolve this issue.
Upon building of the backend, 'nest start' is run and the error appears seconds later.
../node_modules/@types/jasmine/ts3.1/index.d.ts:21:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: beforeAll, beforeEach, afterAll, afterEach, describe, fdescribe,
xdescribe, it, fit, xit, expect, DEFAULT_TIMEOUT_INTERVAL, CustomMatcherFactory, CustomEqualityTester
21 type ImplementationCallback = jasmine.ImplementationCallback;
~~~~
../node_modules/@types/jest/index.d.ts:32:1
32 declare var beforeAll: jest.Lifecycle;
~~~~~~~
Conflicts are in this file.
../node_modules/@types/jasmine/ts3.1/index.d.ts:309:15 - error TS2428: All declarations of 'ArrayContaining' must have identical type parameters.
309 interface ArrayContaining<T> extends AsymmetricMatcher<any> {
~~~~~~~~~~~~~~~
../node_modules/@types/jasmine/ts3.1/index.d.ts:313:15 - error TS2428: All declarations of 'ObjectContaining' must have identical type parameters.
313 interface ObjectContaining<T> extends AsymmetricMatcher<any> {
NestJS should build.
I believe potentially excluding the jasmine files from the tsconfig might resolve it, so I added in '../node_modules' to both of the tsconfig.json files but it has made no difference.
Nest version: 6.14.2
Package Manager: Yarn
Node version: 13.8.0
Platform: Mac
We had the same problem the other day. We could solve the problem by adding the types with the nohoist option of yarn (https://classic.yarnpkg.com/blog/2018/02/15/nohoist/).
So what you could try is replacing your workspaces configuration in the root package.json with this:
"workspaces": {
"packages": ["packages/*"],
"nohoist": ["**/@types/jest", "**/@types/jasmine"]
}
We had the problem with handlebars but this solved it for us
This issue is not specifically related to NestJS.
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.
Thank you for the issue resolve and will use discord in the future thanks!
@arkraft I've just tried the root "nohoist" and have deleted my yarn.lock file and node_modules to reinstall them but it does not seem to be working. Any ideas why?
Are the types still installed into the root node_modules directory?
I can't see them in there, there are some karma modules and some eslint modules but no jasmine. there is an @jest module in there. Apparently this issue is due to the tsconfig file being searched for at root level and not in the subfolder/subdirectory/subproject.
Most helpful comment
We had the same problem the other day. We could solve the problem by adding the types with the nohoist option of yarn (https://classic.yarnpkg.com/blog/2018/02/15/nohoist/).
So what you could try is replacing your workspaces configuration in the root package.json with this:
We had the problem with handlebars but this solved it for us