为什么 react-scripts 有可选链接的编译错误?

Why is react-scripts having a compile error for optional chaining?

我已经将 typescript 升级到至少 3.7,这是可选链接出现的时候。 react-scripts 也是最新的。然而,当我 运行 npm run build:

时,以下行不断抛出以下错误
> react-scripts build

Creating an optimized production build...
Failed to compile.

./src/myfile.tsx
  Line 172:25:  Parsing error: Expression expected

这是“违规”行:

   const result = item.get(first)?.get(second);

这是我的 package.json:

{

  project details...

  "dependencies": {

    other dependencies here...

    "react-scripts": "^3.4.3",
    "@typescript-eslint/parser": "^2.5.0",
    "cross-env": "6.0.3",
    "typescript": "^3.7.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "cross-env CI=true react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

这是我的 tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "src",
    "target": "es2020",
    "allowJs": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "lib": ["es2020", "dom"],
    "skipLibCheck": false
  },
  "include": ["src"]
}

我的 IDE(VS 代码)中没有任何波浪线,所以至少可以正确读取它。

我怎样才能让可选链接在这里很好地发挥作用? react-scripts 会在我的 package.json 中忽略我的 tsconfig.json and/or typescript 吗?

错误提示问题所在:Parsing error

虽然 react-scriptstypescript 设置为正确的版本,但 eslint 包需要更新。 运行 npm i eslint@^6.6 修复了问题。