I’ve been having an issue with developing locally on the Typescript track.
The issue is that VSCode will not recognize the type definitions for Jest after
Yarn installing on a newly cloned exercise, and is also not fixed by manually installing the type definitions using
yarn add @types/jest, and also isn’t recognizing them when globally adding the types to my system using
yarn dlx add @types/jest.
I’ve been playing around with the
tsconfig files to no avail.
This only affects the type definitions of Jest functions inside of the test file, such as
Describe, and actually has no relevance to the actual running of the tests. What i’m trying to say is that
Yarn test executes and has no issues when using the terminal, but my test files for the exercises are riddled with type errors for Jest.
I have managed to get around this and fix it by:
Npm i --save-dev @types/jestto manually generate a node_modules folder (Yarn 3 no longer creates this folder that contains the type definition files)
Yarn installagain in order to install the dependencies via yarn, but the code editor will no longer complain about a missing type definition file for Jest.
I’ve been trying to find a permanent solution for this, as I do not like mixing Yarn and NPM to handle the packages of each exercise. When I do
npm i --save-dev @types/jest it creates a whole bunch of new changes in version control that is absolutely gross
I think it’s realistic that this is a simple configuration error in my local workspace, but I’ve been trying to figure it out for a few hours and thought I’d make a post just in case someone else knows what is going on here.