Andrew
Andrew

Reputation: 1526

How to disable ALL type checking in *.test.* files (including imported components)

"exclude": ["*.test.ts", "*.test.tsx"] in tsconfig only prevents type checking of the test specific types (e.g. describe, it, expect, etc). I'm still seeing errors for imported Components within every test file in vscode. The only way to disable these imported component errors is with //@ts-nocheck at the start of every test file.

Is there a way to disable ALL type checking for all test files from the tsconfig, including any imported components from non-test files?

full tsconfig.json file (Create React App project)

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "noImplicitAny": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": ["src"],
  "exclude": ["*.test.ts", "*.test.tsx"]
}

Upvotes: 9

Views: 8113

Answers (1)

Andrew
Andrew

Reputation: 1526

I ended out going with the disable per file option listed in this other question

How can I disable all typescript type checking?

If your tests are all in 1 folder you could try to exclude that folder, or go with disabling the .js file extension also listed in that thread.

Upvotes: 1

Related Questions