TS: Object literals can specify only known properties, and "test" is not in type "UserConfig"
See original GitHub issueDescribe the bug
This is a type error, please tell me the correct solution.
Reproduction
/// <reference types="vitest" />
import type { ConfigEnv, UserConfig } from 'vite'
export default ({ command, mode }: ConfigEnv): UserConfig => {
return {
test: {},
}
}
System Info
mac os
Used Package Manager
yarn
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
'test' does not exist in type 'UserConfigExport', even with ...
I have found a workaround for this problem - creating separate vitest.config.ts file. As docs states: Create vitest.config.ts , which will have the...
Read more >types/nodemailer 6.2.0 & Typescript 3.5.1 Failure · Issue #35847
Object literal may only specify known properties, and 'host' does not exist in type 'Transport | TransportOptions'. When calling:.
Read more >Raspberry integration test - Help - Edge Impulse Forum
Object literal may only specify known properties, but 'device' does not exist in type '{ deviceId: string; intervalMs: number; }'.
Read more >clean-code-typescript - GitHub Pages
When someone looks at the function signature, it's immediately clear what properties are being used. It can be used to simulate named parameters....
Read more >Configuring Vite
Note if an inline config is provided, Vite will not search for other PostCSS config sources. css.preprocessorOptions #. Type: Record<string, object>. Specify ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So, this happens when you have several Vite versions installed. Check your lockfile and resolve the inconsistency. You can also bypass this by using
defineConfigfromvitest/config. Closing issue since this is not Vitest problem.Exact same problem here:
One of our devs was so smart to cast the
defineConfig({} as Parameters<typeof defineConfig>[0])