解决 eslint 报错 找不到模块“xxx.vue”或其相应的类型声明

问题描述:

引入组件/ts type 声明,eslint 报错 找不到模块“xxx.vue”或其相应的类型声明

项目环境:

ts + vue3

问题解决:

在项目根目录下新建文件 shims-vue.d.ts,内容如下:

//declare声明宣告, 声明一个ambient module(即:没有内部实现的 module声明)

declare module "*.vue" {
  import { App, defineComponent } from "vue";
  const component: ReturnType<typeof defineComponent> & {
    install(app: App): void;
  };
  export default component;
}

猜你喜欢

转载自blog.csdn.net/xiamoziqian/article/details/129317431