reactjs - Kuinka ratkaista jäsentämisvirhe, kun vientityyppiä käytetään CRA Typescript -ympäristössä


Rakennan sovellusta CRA TypeScript -mallilla.

Kun käytin tätä koodia, ilmenee jäsentämisvirhe.

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

Nämä ovat osa minun package.json ja .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"
  },

miten voin ratkaista tämän?

Vastaus #1

En ole ihan varma, miten korjata, joten poistin käytöstä ja otin käyttöön.

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

VAIHTOEHTO :

Tutkimuksessani monet ihmiset pystyivät korjaamaan ongelman lataamalla ympäristönsä uudelleen. Voimme tehdä tämän VS Codessa seuraavasti:

  1. cmd+shift+p (ctrl+shift+p)
  2. >Reload Window
  3. syötä

Tämä lataa uudelleen VS Code -ikkunan, jossa olet, ikään kuin olisit juuri avannut projektin.