-
Notifications
You must be signed in to change notification settings - Fork 461
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
fix: vitest tsconfig should include all files under src
#56
Conversation
Fixes vuejs#55 Fixes the case that a `.spec.ts` file inside `__test__/` imports a module 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`, which seems 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 |
So now:
|
cypress-ct should also add vitest style
So we should split tsconfig to prevent global variables pollution. |
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… |
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: