- Notifications
You must be signed in to change notification settings - Fork477
fix: vitest tsconfig should include all files undersrc
#56
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Fixesvuejs#55Fixes the case that a `.spec.ts` file inside `__test__/` imports amodule outside of `__test__/` (a cross-(typescript-)project reference).Note that TypeScript looks for `include` patterns in `references`top-down, so `tsconfig.app.json` must come before `tsconfig.vitest.json`so that the `src/**` modules can get the most-accurate type hints.The previous tsconfig only works for `.vue` imports in `.spec.ts`, whichseems to be a Volar bug. We shouldn't rely on that.This fix is a more accurate configuration.
Cc@cexbrayat I think you might be interested in this fix, too… |
Hmm interesting, that's what we were missing. One question though: where does ts know that |
haoqunjiang commentedFeb 15, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
So now:
|
cypress-ct should also add vitest style
So we should split tsconfig to prevent global variables pollution. |
paparent commentedFeb 15, 2022
Regarding global variable pollution, I managed to do this in my {"extends":"@vue/tsconfig/tsconfig.node.json","include": ["test-setup.ts","src/**/__tests__/*"],"compilerOptions": {"composite":true,"baseUrl":".","paths": {"@/*": ["./src/*"] },"types": ["node","jsdom","vitest/globals"] }} having I like having different tsconfig files, but it gets confusing! |
Makes sense. Let me merge this PR and release a patch first. And I'll fix the Cypress-CT issue in another PR. At least it is still working… |
Uh oh!
There was an error while loading.Please reload this page.
Credit to@xiaoxiangmoe
Fixes#55
Fixes the case that a
.spec.ts
file inside__test__/
imports amodule outside of
__test__/
(a cross-(typescript-)project reference).Note that VSCode language service looks for
include
patterns inreferences
top-down, so
tsconfig.app.json
must come beforetsconfig.vitest.json
so that the
src/**
modules can get the most-accurate type hints.The previous tsconfig only works for
.vue
imports in.spec.ts
, whichseems to be a Volar bug. We shouldn't rely on that.
This fix is a more accurate configuration.
Vitest TypeScript projects created prior to
create-vue
3.1.6 can apply the following patch to the projects: