Dan*_*cki 2 typescript vue.js typescript-typings nuxt.js vue-test-utils
npm run dev在运行我开发的 using时,我遇到了一个非常奇怪的错误Nuxt.js,它有Vue.js组件。也就是说,在运行应用程序时,我看到与TypeScript诸如相关的错误TS2749: 'About' refers to a value, but is being used as a type here. Did you mean 'typeof About'?,即使npm run test没有显示任何内容。
我的spec.ts文件带有抱怨行
import { shallowMount, Wrapper } from "@vue/test-utils";
import About from "@/pages/about.vue";
describe("About", () => {
const wrapper: Wrapper<About> = shallowMount(About); // <-- Complaining line
...
}
Run Code Online (Sandbox Code Playgroud)
在设置打字之前突出显示时,类型应该没问题,它显示了下面的类型。
建议的解决方案会const wrapper: Wrapper<typeof About> = shallowMount(About);生成另一个TypeScript错误,导致测试无法编译。即,TS2344: Type 'ExtendedVue<Vue, unknown, unknown, { setLocation: any; }, unknown>' does not satisfy the constraint 'Vue'. Type 'VueConstructor<{ setLocation: any; } & Vue>' is missing the following properties from type 'Vue': $el, $options, $parent, $root, and 32 more.
我不知道为什么test是沉默的,而TypeScript在本地运行应用程序时开始抱怨测试本身。顺便说一句,它们都通过了,并且应用程序可以编译。它只是与TypeScript中的某种类型的输入有关@vue/test-utils。
| 归档时间: |
|
| 查看次数: |
5047 次 |
| 最近记录: |