ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.31k stars 1.36k forks source link

🐛[BUG]紧急,可能是新旧版本问题,项目编译一直报类型错误!!! #602

Closed haoyinag closed 4 years ago

haoyinag commented 4 years ago

🐛 bug 描述

之前用的是下面的版本

"@amap/amap-jsapi-types": "^0.0.4",
    "@ant-design/pro-layout": "^5.0.9",
    "@ant-design/pro-table": "^2.2.7",

后来不知道怎么回事,可能是升级了还是怎么,因为对webpack或者包的缓存不是很熟悉,不知道啥原因 使用any解决了一些问题,

之前类似的问题如下解决

**import React, { FC, memo, useState } from "react";
import { Modal, Tabs } from "antd";
import { useSelector } from "umi";
import ProTable, { ProColumns } from "@ant-design/pro-table";
import ProTable from "@ant-design/pro-table";

import { Store } from "antd/es/form/interface";

@ -56,7 +56,7 @@ const AllotModal: FC<IPros> = memo(({ stationId, onOk, ...props }) => {
  };

  // 列配置
  const columns: ProColumns<TableListItem>[] = [
  const columns: any[] = [
    { title: "id", dataIndex: "id", hideInSearch: true, hideInTable: true },
    { title: "配送员", dataIndex: "name", hideInSearch: true },
    { title: "手机号", dataIndex: "mobile", hideInSearch: true },

然后本地编译通过了,结果Jenkins打包不通过 打包报错信息

ERROR in /usr/local/tomcat.jenkins/jenkins/workspace/vmcmall/angsi-cli-react-admin/mock/staff.ts(31,7):
31:7 Type 'string' is not assignable to type 'never'.
    29 |       tool: 0,
    30 |       role: 1,
  > 31 |       createTime: "2020-5-11",
       |       ^
    32 |       status: 0,
    33 |     });
    34 |   }

 error  in /usr/local/tomcat.jenkins/jenkins/workspace/vmcmall/angsi-cli-react-admin/mock/staff.ts

ERROR in /usr/local/tomcat.jenkins/jenkins/workspace/vmcmall/angsi-cli-react-admin/mock/staff.ts(32,7):
32:7 Type 'number' is not assignable to type 'never'.
    30 |       role: 1,
    31 |       createTime: "2020-5-11",
  > 32 |       status: 0,
       |       ^
    33 |     });
    34 |   }
    35 | }

初步怀疑是包迁移或者包的类型检查更改的问题?也不知道该怎么描述。

已经通过rm -rf node_modules然后npm cache clear --force等删除包和缓存的方式都试过了,就是无法正常编译。

🏞 期望结果

代码太多了,一个个改any不现实,求解有没有快速的办法先解决打包上线的问题

💻 复现代码

如果找不到办法后续尽量提供一个复现

© 版本信息

{
  "private": true,
  "scripts": {
    "start": "cross-env API_ENV=dev umi dev",
    "start:test": "cross-env API_ENV=test umi dev",
    "build:dev": "cross-env API_ENV=dev umi build",
    "build:dev2": "cross-env API_ENV=dev umi build",
    "build:test": "cross-env API_ENV=test umi build",
    "build:prod": "cross-env API_ENV=prod umi build",
    "analyze": "cross-env ANALYZE=1 umi build",
    "postinstall": "umi generate tmp",
    "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
    "test": "umi-test",
    "test:coverage": "umi-test --colors --coverage"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,jsx,less,md,json}": [
      "prettier --write"
    ],
    "*.ts?(x)": [
      "prettier --parser=typescript --write"
    ]
  },
  "dependencies": {
    "@amap/amap-jsapi-types": "^0.0.4",
    "@ant-design/pro-layout": "^5.0.9",
    "@ant-design/pro-table": "^2.2.7",
    "@types/jest": "^25.2.1",
    "@types/react": "^16.9.34",
    "@umijs/hooks": "^1.9.2",
    "@umijs/preset-react": "1.x",
    "@umijs/test": "^3.1.1",
    "antd-dayjs-webpack-plugin": "^1.0.0",
    "cross-env": "^7.0.2",
    "html2canvas": "^1.0.0-rc.5",
    "lint-staged": "^10.0.7",
    "postcss-px-to-viewport": "^1.1.1",
    "prettier": "^2.0.5",
    "react": "^16.12.0",
    "react-amap": "^1.2.8",
    "react-dom": "^16.12.0",
    "stylus": "^0.54.7",
    "stylus-loader": "^3.0.2",
    "ts-md5": "^1.2.7",
    "typescript": "^3.8.3",
    "umi": "^3.1.1",
    "yorkie": "^2.0.0"
  },
  "__npminstall_done": false
}

🚑 其他信息

image

chenshuai2144 commented 4 years ago

这个和 protable 没关系的,你为什么会编译 mock 数据