-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(globals): enhance configuring globals docs #5687
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -382,6 +382,18 @@ To get TypeScript working with the global APIs, add `vitest/globals` to the `typ | |||
} | |||
``` | |||
|
|||
Sometimes the configuration mentioned above might not work because your workspace cannot find the types for `vitest/globals`. If that's the case, you can add `typeRoots` to your `tsconfig.json` file. Afterward, try restarting your TypeScript server. For example in VSCode, press `F1` and select `TypeScript: Restart TS server` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's Vitest's documentation's place to instruct restarting IDEs Typescript servers. It's IDE specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are true @AriPerkkio , I think VSCode having a problem to recognize vitest/globals, adding that steps make it works but after for some times I can use vitest/globals without typeRoots and restarting VSCode TS server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions regarding that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really Vitest specific? Or is VSCode just not automatically restarting the Typescript server after tsconfig.json
was modified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue isn't specific to vitest, but since the vitest/globals setting requires tsconfig.json, this buggy behaviour in VSCode could affect the behavior of the documentation steps. @AriPerkkio
{ | ||
"compilerOptions": { | ||
"types": ["vitest/globals"], | ||
"typeRoots": ["./node_modules/@types/", "./types", "./node_modules"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what cases doesn't the default typeRoots
work? Could you setup a minimal reproduction with https://vitest.new/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's IDE specific. @AriPerkkio
Description
Setting
vitest/globals
may not work smoothly without configuring the types root explicitly.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.