我正在使用带有Typescript的React.js,我遇到了这个错误:
node_modules\@types\sweetalert\index.d.ts
error TS2451: Cannot redeclare block-scoped variable 'sweetAlert'.
依赖关系:
"dependencies": {
"react": "^16.1.0",
"react-dom": "^16.1.0",
"react-router-dom": "^4.2.2",
"react-scripts-ts": "2.8.0",
"sweetalert": "^2.0.8"
},
"devDependencies": {
"@types/jest": "^21.1.6",
"@types/node": "^8.0.51",
"@types/react": "^16.0.22",
"@types/react-dom": "^16.0.3",
"@types/react-router-dom": "^4.2.1",
"@types/sweetalert": "^1.1.28"
}
答案 0 :(得分:0)
无法重新声明使用块范围的变量' sweetAlert'。
sweetAlert
是用TypeScript编写的,您不再需要@types/sweetAlert
。
npm uninstall @types/sweetAlert
利润