Typescript Vue3中出错-参数类型为';导入类型(“./dist/vue”)&x27;不可分配给类型为';PublicapicComponent';

Typescript Vue3中出错-参数类型为';导入类型(“./dist/vue”)&x27;不可分配给类型为';PublicapicComponent';,typescript,vue.js,Typescript,Vue.js,我使用cli v4.4.1安装vue 之后,我运行此命令更新到Vue3:vue add vue next 当我打开main.ts时,我得到了typescript错误: Argument of type 'typeof import("c:/../vue-app/node_modules/vue/dist/vue")' is not assignable to parameter of type 'PublicAPIComponent'. 我需要做什么来解决这个错误 我通过更新src/vue.d

我使用cli v4.4.1安装vue

之后,我运行此命令更新到Vue3:
vue add vue next

当我打开
main.ts
时,我得到了typescript错误:

Argument of type 'typeof import("c:/../vue-app/node_modules/vue/dist/vue")' is not assignable to parameter of type 'PublicAPIComponent'.
我需要做什么来解决这个错误


我通过更新
src/vue.d.ts
中*.vue模块的定义文件解决了这个问题:

declare module "*.vue" {
  import { defineComponent } from "vue";
  const component: ReturnType<typeof defineComponent>;
  export default component;
}
声明模块“*.vue”{
从“vue”导入{defineComponent};
常量组件:返回类型;
导出默认组件;
}

来源:

此处相同,无法为应用程序提供服务,因为此解决方法:
createApp(应用程序作为任何应用程序)
。Vue团队发布了vue3,但没有任何努力,我们发现了一个问题:(对我来说不起作用。因此我必须使用Jon Sud在原始帖子的评论中建议的变通方法:
createApp(app as any)
。既不工作,又以
any
的方式强制转换,这首先就违背了使用ts的目的