错误TS2430:接口“ RcFile”错误地扩展了antd中的接口“文件”

时间:2018-08-08 01:29:32

标签: reactjs typescript antd

C:\Users\SCC\Desktop\xxx\web-shop\node_modules\antd\lib\upload\interface.d.ts
(6,18): error TS2430: Interface 'RcFile' incorrectly extends interface 
'File'.
  Types of property 'lastModifiedDate' are incompatible.
  Type 'Date | undefined' is not assignable to type 'Date'.
  Type 'undefined' is not assignable to type 'Date'.

我在家中从git上将其取下,然后运行,但我犯了一个错误。我不知道是什么问题,有人可以帮我吗?谢谢,以下是我的package.json文件

"dependencies": {
"antd": "^3.7.3",
"less": "^3.8.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router-dom": "^4.3.1",
"react-scripts-ts": "2.16.0"
},
"devDependencies": {
"@types/history": "^4.7.0",
"@types/jest": "^23.3.0",
"@types/react": "^16.4.7",
"@types/react-dom": "^16.0.6",
"@types/react-router-dom": "^4.3.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"less-loader": "^4.1.0",
"react-app-rewire-less": "^2.1.2",
"react-app-rewired": "^1.5.2",
"ts-import-plugin": "^1.5.4",
"typescript": "^2.9.2"
},

2 个答案:

答案 0 :(得分:0)

antd库最近对其类型进行了重大更改,并且您的版本约束自动更新为同一主版本中的最新版本,从而引入了错误。如果您修复了antd版本(删除了“ ^”)并再次运行npm install,就可以了。

答案 1 :(得分:-2)

打开C:\Users\SCC\Desktop\xxx\web-shop\node_modules\antd\lib\upload\interface.d.ts,然后删除lastModifiedDate后面的