TS error in defineConfig: 'test' does not exist in type 'UserConfigExport' #1106
-
Hello, I have some problems with setting up vitest to work with vite and ts... I added reference types as mentioned in https://vitest.dev/config/#configuration but it didn't help. Here are my tsconfigs: tsconfig.json
tsconfig.node.json
Any ideas? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
I had the same problem and defining it like this with an arrow function fixed the issue. export default defineConfig(() => ({
build: {
// ...
},
test: {
// ...
},
})); |
Beta Was this translation helpful? Give feedback.
-
Looking at one of my other projects, the following reference at the top of your config file will also fix the issue, instead of needing to use a function. /// <reference types="vitest/config" /> |
Beta Was this translation helpful? Give feedback.
-
Just merge the UserConfig interface & InlineConfig interface and get the full type safety 🚀 import { defineConfig, type UserConfig } from 'vite'
import type { InlineConfig } from 'vitest/node'
export default defineConfig({
build: {
...
},
test: {
...
},
} as UserConfig & { test: InlineConfig }) |
Beta Was this translation helpful? Give feedback.
I had the same problem and defining it like this with an arrow function fixed the issue.