Search code examples
node.jstypescripteslinttsconfig

ESLint: Parsing error: Unknown compiler option 'noUncheckedIndexedAccess'


I changed the configuration of my tsconfig.json file of a node project as following and now it is giving ESLint: Parsing error: Unknown compiler option 'noUncheckedIndexedAccess' error.

ESLint Error

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
      "outDir": "lib",
      "sourceMap": true,
      "declaration": false,
      "moduleResolution": "node",
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "target": "es2018",
      "typeRoots": [
          "node_modules/@types"
      ],
      "skipLibCheck": true,
      "lib": [
          "es2017",
          "dom"
      ],
      "module": "CommonJS",
      "baseUrl": "./",
      "noUnusedLocals": true,
      "noUnusedParameters": true,
      "noUncheckedIndexedAccess": true,
      "strictNullChecks": true
  }
}

Is there any way to resolve this issue?


Solution

  • As HTN pointed out in his comment, noUncheckedIndexedAccess is available since 4.1. The docs confirm this.

    As a result, this is the problematic line:

    "noUncheckedIndexedAccess": true,
    

    your Typescript 3.8.0 is older than the feature it attempts to use, hence the error. You can either go with the current Typescript you have, but removing that line or you could upgrade Typescript to at least 4.1 version. Both approaches would solve the issue, but Typescript version upgrade is generally considered to be a better approach as it will provide new options for you, instead of you having to restrict access to features.