How to get rid of the warning .ts file is part of the TypeScript compilation but it's unused

后端 未结 16 1154
天命终不由人
天命终不由人 2020-12-30 18:20

I Just updated angular to latest 9.0.0-next.4. I am not using routing but suddenly after updating I keep seeing this warning. How Do I remove this warning

16条回答
  •  长情又很酷
    2020-12-30 18:45

    I began to see the warnings in Angular 10 which is a little surprising based on the fact it was a new app created using the CLI out of the box and I got the messages when doing a prod build for test.ts and enviornments.prod.ts. I'd think these files would be excluded by default, but they are not and that's odd.

    The deal is these files are not needed for TypeScript transpolation; they don't need .js versions of the files to be bundled and sent to the browser. The test.ts and environments.prod.ts files are a means to an end for build time requirements in Angular. Therefore they can be added to the exclude section in tsconfig.app.json or applicable TypeScript configuration file in your app like below:

      "exclude": [
        "src/**/*.spec.ts",
        "src/test.ts",
        "src/environments/environment.prod.ts"
      ]
    

    Once these are added as above, the warning will not show anymore.

提交回复
热议问题