I have the following tsconfig configuration:
{
"include": ["tests/**/*.ts"],
"exclude": [],
"compilerOptions": {
"composite": true,
"lib": [],
"skipLibCheck": true,
"outDir": "lib",
"types": ["vitest/globals"]
}
}
As I have defined types for vitest/globals so yarn vitest cmd is working fine and executing the tests cases as well.
But in VS Code its showing me the following error:

How I can fix or silence this issue in vs-code?
I had to add the following to my .eslintrc.json file to fix this issue in a test setup module:
"globals": {
"vi": true
},
If you're using TypeScript, you should also add the following to your compilerOptions in your tsconfig.json. (You already had this, but I'm mentioning it anyway in case it helps someone else):
"types": ["vitest/globals"]
My solution for this problem was to increase the ecmaVersion in the .eslintrc.js file from 2020 to 2022 like this:
"parserOptions": {
"ecmaVersion": 2022,
}
Since you are using TypeScript, you could also try setting the target to 2022 like this:
"compilerOptions": {
"target": "ES2022"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With