我最近在使用vite构建vue + ts项目时,出现找不到导入的类型的报错,而编辑器中代码却未提示报错,在dev或build时却会出现报错,所以将这个坑发出来避免大家踩坑却找不到原因
我遇到的这种情况,目前是因为导入时未加type前缀,导致找不到导入的类型:
import { ref, computed, Ref, ComputedRef } from 'vue';
import { defineStore, StoreDefinition } from 'pinia';
解决方法:在导入类型前面加上type字段
import { ref, computed, type Ref, type ComputedRef } from 'vue';
import { defineStore, type StoreDefinition } from 'pinia';
这样就解决了以上问题