尝试在已经存在的vite (vue 3,typescript)项目上设置最有活力的项目。
我的vite.config.ts看起来是这样的:
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
},
plugins: [vue()],
});
但在VS代码中,它抱怨道:
在悬停时我看到:
类型'{ test:{ globals: boolean;环境: string;};plugins: Plugin[];}‘的参数不能分配给类型'UserConfigExport’的参数。对象文字只能指定已知的属性,并且在类型‘UserConfigExport.ts(2345)中不存在'test’。
如果我改变这句话,我就能让它消失:
import { defineConfig } from 'vite';
至:
import { defineConfig } from 'vitest/config';
但是为什么呢?这怎么回事?为什么我必须从vitest导入defineConfig才能使它支持测试属性?
https://stackoverflow.com/questions/72146352
复制相似问题