Closed rikisamurai closed 2 months ago
Your tsconfig.json
doesn't include
any files.
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
By default Vitest uses the tsconfig.json
that it can find: https://vitest.dev/config/#typecheck-tsconfig
So to make your repro work, let's define one of those custom tsconfig.json
files in Vitest config:
export default defineConfig({
plugins: [react()],
test: {
typecheck: {
enabled: true,
+ tsconfig: 'tsconfig.app.json'
},
},
})
Your
tsconfig.json
doesn'tinclude
any files.{ "files": [], "references": [ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" } ] }
By default Vitest uses the
tsconfig.json
that it can find: https://vitest.dev/config/#typecheck-tsconfigSo to make your repro work, let's define one of those custom
tsconfig.json
files in Vitest config:export default defineConfig({ plugins: [react()], test: { typecheck: { enabled: true, + tsconfig: 'tsconfig.app.json' }, }, })
Thank you very much for your help❤️! Is it expected that Vitest won't refer to references in this situation? Many beginners, like me, might encounter this issue after creating a project using the Vite template and then adding Vitest.
Oh right, there's references
. Vitest uses tsc --noEmit --pretty false -p tsconfig.json
to run the typechecks. Looks like references
do not emit any type errors when --build
flag is not used.
Edit: Duplicate, slow network on train 🫠
Oh right, there's references
. Vitest uses tsc --noEmit --pretty false -p tsconfig.json
to run the typechecks. Looks like references
do not emit any type errors when --build
flag is not used.
See #3752. The references
related behaviour was discussed there.
Thanks @mrazauskas, let's track this on https://github.com/vitest-dev/vitest/issues/3752.
Describe the bug
I followed the official examples to use Vitest and Vite for type checking, but even when there are type errors, no errors are reported, and the test cases still pass.
there are type errors, but still pass.
Reproduction
stackBlitz: https://stackblitz.com/~/github.com/rikisamurai/vitest-issue
or
and follow https://github.com/vitest-dev/vitest/blob/main/examples/typecheck/test/type.test-d.ts
System Info
Used Package Manager
pnpm
Validations