element-plus打包报错/vue3.0+vite+ts别名引入ts文件报错

element-plus报错内容

报错原因如下
vue-tsc 是对ts类型做检测的 element对ts支持并不是很友好所以报错 但是不影响正常使用

Cannot find name ‘Nullable’. Cannot find name ‘ComponentSize’.
解决办法

package.json文件修改build参数删改成下面参数

"build": "vite build",

别名引入报错问题

  1. tsconfig.json 文件添加如下代码
 "paths": {
      "@ts/*": [
        "./src/*"
      ]
    },
  1. vite.config.ts 文件中的resolve.alias添加如下配置
  {
        find: /\/@ts\//,
        replacement: pathResolve('src') + '/',
      },

引入方式

import { key } from "/@ts/store/index";

我的配置文件如下

{
 "compilerOptions": {
   "target": "esnext",
   "module": "esnext",
   "moduleResolution": "node",
   "strict": true,
   "jsx": "preserve",
   "sourceMap": true,
   "resolveJsonModule": true,
   "esModuleInterop": true,
   "lib": [
     "esnext",
     "dom"
   ],
   "types": [
     "vite/client"
   ],
   "paths": {
     "/@ts/*": [
       "./src/*"
     ]
   },
 },
 "include": [
   "src/**/*.ts",
   "src/**/*.d.ts",
   "src/**/*.tsx",
   "src/**/*.vue"
 ]
}

你可能感兴趣的:(vue,vue,vue3.0常见问题,vue3.0+ts别名引入报错,elementPlus打包报错)