pzavolinsky / ts-unused-exports

ts-unused-exports finds unused exported symbols in your Typescript project
MIT License
749 stars 49 forks source link

Unknown compiler option 'noUncheckedIndexedAccess' #187

Closed GollyJer closed 3 years ago

GollyJer commented 3 years ago

Hi, I was new to it and it took me a while to realize I'm using an unsupported setting in tsconfig.json. https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess

This is a really cool package. Thanks!

mrseanryan commented 3 years ago

Thanks for reporting!

This setting is new in TS 4.0.1 so far, we've only used with TS 4.0.0 - so probably that explains why this setting not recognised.

related: is there any way to allow for such unexpected settings (since this could easily re-occur...)

mrseanryan commented 3 years ago

hi @GollyJer am having some trouble reproducing this issue.

This PR has a test tsconfig.json:

https://github.com/pzavolinsky/ts-unused-exports/pull/190/files#diff-e2d77c52f38bf80ae1e0ca8d4b16158f1f4db001e235bbd8edb0abc82678e045

The results are PASS for TypeScript 4 (and FAIL for TypeScript 3, as you'd expect):

https://github.com/pzavolinsky/ts-unused-exports/pull/190/checks?check_run_id=1953760178

mrseanryan commented 3 years ago

@GollyJer a couple of questions:

  1. Which version of ts-unused-exports are you using?

Previously, ts-unused-exports was bundling its own version of TypeScript, but we stopped doing that since version 7.0.0

  1. Can you confirm which version of TypeScript you are using?

  2. Finally, can you post your tsconfig.json (or at least, the relevant part)

Thank you Sean

GollyJer commented 3 years ago

ts-unused-exports 7.0.1 typescript 4.0.7

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "allowUnreachableCode": true,
    "baseUrl": ".",
    "checkJs": true,
    "jsx": "react-native",
    "lib": ["dom", "esnext"],
    "moduleResolution": "node",
    "noEmit": true,
    "noErrorTruncation": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "paths": {
      "~/*": ["./*"]
    },
    "plugins": [
      {
        "NOTE": "https://github.com/microsoft/typescript-styled-plugin/issues/58",
        "lint": {
          "validProperties": [
            "aspect-ratio",
            "box-shadow",
            "elevation",
            "margin-vertical",
            "margin-horizontal",
            "padding-horizontal",
            "padding-vertical",
            "resize-mode",
            "shadow-color",
            "shadow-opacity",
            "shadow-offset",
            "shadow-radius",
            "text-align-vertical",
            "tint-color"
          ]
        },
        "name": "typescript-styled-plugin"
      }
    ],
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "target": "ESNext",
    "types": ["jest", "webpack-env"]
  }
}

Here is the error when noUncheckedIndexedAccess is included in tsconfig.

mrseanryan commented 3 years ago

@GollyJer I found the problem.

That setting was introduced in TypeScript version 4.1

But you are using an earlier version 4.0.7

If you want to use that TypeScript setting (noUncheckedIndexedAccess) then you need to use at least TypeScript 4.1 or higher.

GollyJer commented 3 years ago

That is super embarrassing. Sorry to waste your time and thanks for the help.

mrseanryan commented 3 years ago

@GollyJer no problem!