My tsconfig file getting overwritten every time I run tests

Viewed 433

Every time I would run tests, my tsconfig.json file would get overwritten and after test passing successfully it will fail with:

rpt2: config error TS6046: Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'.
(rpt2 plugin) Error: /main/src/index.tsx(1,30): semantic error TS6142: Module './ExampleComponent' was resolved to '/main/src/ExampleComponent/index.tsx', but '--jsx' is not set.

During code run I'll be prompted with message:

The following changes are being made to your tsconfig.json file:
  - compilerOptions.allowJs to be suggested value: true (this can be changed)
  - compilerOptions.skipLibCheck to be suggested value: true (this can be changed)
  - compilerOptions.strict to be suggested value: true (this can be changed)
  - compilerOptions.forceConsistentCasingInFileNames to be suggested value: true (this can be changed)
  - compilerOptions.noFallthroughCasesInSwitch to be suggested value: true (this can be changed)
  - compilerOptions.resolveJsonModule must be true (to match webpack loader)
  - compilerOptions.isolatedModules must be true (implementation limitation)
  - compilerOptions.noEmit must be true
  - compilerOptions.jsx must be react-jsx (to support the new JSX transform in React 17)

I know there are many threads like that, but so far solutions there didn't help. So far I've tried:

  • Setting VSCode to use workspace version of Typescript (4.3.5)
  • Changing tsconfig.json parameters (but no matter what I try changing inside it will get overwritten once I run tests)
  • Updating VSCode to lates version
  • restarting TS server

My original tsconfig:

{
  "compilerOptions": {
    "outDir": "dist",
    "module": "esnext",
    "lib": ["dom", "esnext"],
    "moduleResolution": "node",
    "jsx": "react",
    "sourceMap": true,
    "declaration": true,
    "esModuleInterop": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "allowSyntheticDefaultImports": true,
    "target": "es5",
    "types": ["webrtc"]
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist"]
}

And after I run tests:

{
  "compilerOptions": {
    "outDir": "dist",
    "module": "esnext",
    "lib": [
      "dom",
      "esnext"
    ],
    "moduleResolution": "node",
    "jsx": "react-jsx",
    "sourceMap": true,
    "declaration": true,
    "esModuleInterop": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "allowSyntheticDefaultImports": true,
    "target": "es5",
    "types": [
      "webrtc"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}

I also got react-app-env.d.ts file generated with:

/// <reference types="react-scripts" />

And settings.json with:

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

I use:

  • typescript 4.3.5
  • react-scripts 4.0.3
  • react 17.0.2
0 Answers
Related