ERROR(TypeScript) Cannot find type definition file for 'element-plus/global'

408 阅读1分钟

运行环境:vue3 + typescript5.4

运行报错:找不到“element-plus/global”的类型定义文件。 程序包含该文件是因为: 在 compilerOptions 中指定的类型库 "element-plus/global" 的入口点。

原因:[TypeScript] [All] Cannot find type definition file for 'element-plus/global'. · Issue #12119 · element-plus/element-plus · GitHub

解决办法:

1]将typescript版本回退到5.0

2]"types": ["vite/client", "node", "element-plus/global.d.ts", "unplugin-vue-define-options"],将element-plus/global后加上.d.ts

3]关闭vscode,对该项目重启

不知道以上哪一步的影响,标红消失,之后有时间可以试试ts5.4版本加上.d.ts后重启是否有用。