Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fzn0x
Copy link

@fzn0x fzn0x commented May 8, 2024

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:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented May 8, 2024

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit 4ddc873
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/663b79610d33f700087198bf
😎 Deploy Preview https://deploy-preview-5687--fastidious-cascaron-4ded94.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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`
Copy link
Member

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.

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions regarding that?

Copy link
Member

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?

Copy link
Author

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"]
Copy link
Member

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/ ?

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants