In my Angular 11 application, ng serve
and ng build
don't report any error. But with npm run ng build -- --prod --output-hashing=all
, which happens on the build server, I suddenly see an error:
Error: src/app/administration/clients/licensing-client.ts:7:15 - error TS6133: 'tap' is declared but its value is never read.
7 import { map, tap } from 'rxjs/operators';
~~~
My question is, why is this error not reported already when I do ng serve
? Are those different configurations somehow?
Could you share your angular.json
, and tsconfig.json
?
The tsconfig.json
compiler option that produces this error is
"compilerOptions": {
...
"noUnusedLocals": true,
...
}
Regarding why it heppens in the production mode, and not development:
It may be the AOT compiler and buildOptimization, especially if it is on for the production mode, and off for the development mode. Try turning on AOT for all modes, but disable buildOptimization for the development mode. Otherwise you will have production mode turned on while developing.