gpt4 book ai didi

reactjs - CRA typescript环境导出类型时如何解决解析错误

转载 作者:行者123 更新时间:2023-12-05 08:05:42 29 4
gpt4 key购买 nike

我使用 CRA typescript 模板构建应用程序。

我在使用这段代码时,出现了解析错误。

export type { BaseModalProps } from "./BaseModalProps"
Parsing error: Declaration or statement expected

这些是我的 package.json.eslintrc 的一部分

// package.json
"dependencies": {
"@craco/craco": "^5.6.4",
"@material-ui/core": "^4.11.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"axios": "^0.20.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-facebook-login": "^4.1.1",
"react-google-login": "^5.1.21",
"react-hook-form": "^6.8.1",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"styled-components": "^5.1.1",
"styled-reset": "^4.2.1"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/react-facebook-login": "^4.1.2",
"@types/react-redux": "^7.1.9",
"@types/react-router-dom": "^5.1.5",
"@types/redux-logger": "^3.0.8",
"@types/styled-components": "^5.1.2",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"craco-alias": "^2.1.1",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"husky": ">=4",
"lint-staged": ">=10",
"prettier": "^2.1.1",
"typescript": "^4.0.2"
},
// .eslintrc
"env": {
"browser": true,
"es2020": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "react"],
"extends": [
"plugin:react/recommended",
"airbnb",
"prettier/react",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"tsx": true,
"ts": true,
"d.ts": true
},
"ecmaVersion": 11,
"sourceType": "module"
},

我该如何解决这个问题?

最佳答案

我不确定如何修复所以我 disabled and enabled .

/* eslint-disable */
export type { BaseModalProps } from "./BaseModalProps"
/* eslint-enable */

备选方案:

在我的研究中,很多人都能够通过重新加载他们的环境来修复。我们可以通过以下方式在 VS Code 中执行此操作:

  1. cmd+shift+p (ctrl+shift+p)
  2. >重新加载窗口
  3. 进入

这将重新加载您所在的 VS Code 窗口,就像您刚刚打开项目一样。

关于reactjs - CRA typescript环境导出类型时如何解决解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63871179/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com