Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tsconfig noEmit must be true

I'm using create-react-app and I also have some ts and tsx files. In my tsconfig file (see below) I set noEmit to false because js files need to be emitted. However, every time I start the server, noEmit is set to false with the following message:

The following changes are being made to your tsconfig.json file:
   - compilerOptions.noEmit must be true

When noEmit is set to false, the js files that should be generated from my ts files, aren't generated, which means the app isn't updated. What causes this behaviour? Is there any way to avoid it? Or is the only option to make a seperate tsconfig for the folder with the ts files?

{
  "compilerOptions": {
    "target": "ES2017",
    "module": "esnext",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext",
      "ES2017"
    ],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "strictPropertyInitialization": false,
    "strictNullChecks": false,
    "strict": true,
    "sourceMap": true,
    "noEmit": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules"
  ]
}
like image 392
Brent Avatar asked Apr 17 '20 07:04

Brent


1 Answers

You need to override this compile option in your webpack.config-file, like this:

rules: [
     {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        options: {
           compilerOptions: {
              "noEmit": false
           }
        },
        exclude: /node_modules/,
      },
like image 170
Daniel Zarins Avatar answered Nov 05 '22 22:11

Daniel Zarins