我正在更新 React 项目中的一些包,我需要更新打字稿版本,问题是我开始收到以下错误
Parsing error: DeprecationError: 'originalKeywordKind' has been deprecated since v5.0.0 and can no longer be used. Use 'identifierToKeywordKind(identifier)' instead
这是我的package.json
"name": "some_name_here",
"version": "0.1.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.5.0",
"@ant-design/pro-components": "^2.6.34",
"@fullcalendar/core": "^5.11.0",
"@fullcalendar/daygrid": "^5.11.0",
"@fullcalendar/react": "^5.11.1",
"@fullcalendar/timegrid": "^5.11.0",
"@hedgedoc/html-to-react": "^1.4.5",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^7.1.2",
"@types/esri-leaflet-geocoder": "^2.2.3",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/react-router-dom": "^5.1.7",
"@unform/core": "^2.1.3",
"@unform/web": "^2.1.3",
"antd": "^5.10.2",
"antd-img-crop": "^4.13.0",
"antd-mask-input": "^0.1.15",
"axios": "^0.21.1",
"base-64": "^1.0.0",
"cep-promise": "^4.1.0",
"cpf-cnpj-validator": "^1.0.3",
"date-fns": "^2.24.0",
"esri-leaflet": "^3.0.8",
"esri-leaflet-geocoder": "^3.1.3",
"faker": "^5.5.1",
"file-saver": "^2.0.5",
"gerador-validador-cpf": "^5.0.2",
"history": "^5.0.0",
"i18n-js": "^3.9.2",
"js-file-download": "^0.4.12",
"jwt-decode": "^3.1.2",
"leaflet": "^1.7.1",
"leaflet-control-geocoder": "^2.4.0",
"leaflet-geosearch": "^3.3.2",
"leaflet.markercluster": "^1.5.3",
"miragejs": "^0.1.41",
"moment": "^2.29.1",
"pdfmake": "^0.2.4",
"polished": "^4.1.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-audio-player": "^0.17.0",
"react-color": "^2.19.3",
"react-countdown-circle-timer": "^3.2.1",
"react-dom": "^16.13.1",
"react-google-recaptcha": "^2.1.0",
"react-helmet": "^6.1.0",
"react-highlight-words": "^0.17.0",
"react-icons": "^4.2.0",
"react-infinite-scroll-component": "^6.1.0",
"react-leaflet": "^3.2.0",
"react-leaflet-cluster": "^1.0.3",
"react-leaflet-markercluster": "^3.0.0-rc1",
"react-number-format": "^4.7.3",
"react-phone-number-input": "^3.1.47",
"react-player": "^2.9.0",
"react-query": "^3.19.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-spring": "^8.0.27",
"react-toastify": "^7.0.3",
"react-video-js-player": "^1.1.1",
"simple-react-lightbox": "^3.6.9-0",
"styled-components": "^5.2.0",
"typescript": "^5.1.6",
"uuidv4": "^6.2.6",
"webpack-dev-server": "3.11.0",
"yup": "^0.29.3"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jest-environment-jsdom-sixteen",
"eject": "react-app-rewired eject"
},
"jest": {
"collectCoverageFrom": [
"src/pages/**/*.tsx",
"src/components/**/*.tsx",
"src/hooks/*.tsx",
"!src/hooks/index.tsx"
],
"moduleNameMapper": {
"~(.*)$": "<rootDir>/src/$1"
}
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
"devDependencies": {
"@testing-library/react-hooks": "^5.1.0",
"@types/base-64": "^1.0.0",
"@types/faker": "^5.1.7",
"@types/file-saver": "^2.0.5",
"@types/i18n-js": "^3.8.2",
"@types/leaflet": "^1.7.3",
"@types/pdfmake": "^0.1.20",
"@types/react-color": "^3.0.6",
"@types/react-google-recaptcha": "^2.1.0",
"@types/react-helmet": "^6.1.0",
"@types/react-highlight-words": "^0.16.3",
"@types/react-infinite-scroll-component": "^5.0.0",
"@types/react-leaflet-markercluster": "^3.0.0",
"@types/simple-react-lightbox": "^3.6.1",
"@types/styled-components": "^5.1.3",
"@types/yup": "^0.29.7",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"babel-eslint": "^10.1.0",
"babel-plugin-root-import": "^6.6.0",
"customize-cra": "^1.0.0",
"docz": "^2.3.1",
"eslint": "6.8.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.12.0",
"eslint-import-resolver-babel-plugin-root-import": "^1.1.1",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.0",
"jest-environment-jsdom-sixteen": "^1.0.3",
"prettier": "^2.1.2",
"react-app-rewired": "^2.1.8",
"react-test-renderer": "^17.0.1"
}
}
我已经尝试更新
@typescript-eslint/parser
和@typescript-eslint/eslint-plugin
,但无法解决问题。这个问题是在我将 antd 和 typescript 更新到新版本后开始出现的。
您的 package.json 中存在多个依赖关系问题。
react-scripts
该错误最可能的罪魁祸首是
react-scripts
依赖于v3或v4的打字稿,并且没有v5支持。
这可以通过弹出您的应用程序来解决(尽管您应该事先进行备份)
docz
第二个最可能的候选者是
docz
也只支持v3和v4。
只需升级到最新版本即可。docz
@ant-design/pro-components
最不可能但可能令人烦恼的问题是
@ant-design/pro-components
仅支持react
v17及以上版本。
这可以通过升级
或降级react
来解决@ant-design/pro-components
这些是我使用
npm ls typescript
发现的主要问题,它输出对 typescript
有对等/开发/可选/常规依赖的所有包,您可能需要检查 npm ls @typescript-eslint/parser
和 npm ls @typescript-eslint/eslint-plugin