0

I have the latest angular v8 installed and I want to receive basic template errors i get during production also while runing ng serve.

For example

Template

<p (click)="log()">ERROR: {{ errorMessage }}</p>

Controller

log(a){}

Build error

ERROR in apps/manufacturing-tv/src/app/app.component.ts.AppComponent.html(7,9): Expected 1 arguments, but got 0.

or

Template

<p>ERROR: {{ errorMessages }}</p>

ERROR in apps/manufacturing-tv/src/app/app.component.ts.AppComponent.html(7,25): Property 'errorMessages' does not exist on type 'AppComponent'. Did you mean 'errorMessage'?

I've already tried to add the fullTemplateTypeCheck flag but running ng build or ng serve doesn't yield the errors.

{
    "extends": "../../tsconfig.json",
    "compilerOptions": {
        "types": ["jasmine"]
    },
    "angularCompilerOptions": {
        "fullTemplateTypeCheck": true
    },
    "include": ["**/*.ts"]
}

Han Che
  • 8,239
  • 19
  • 70
  • 116

1 Answers1

2

Enable ahead-of-time compilation by calling:

ng serve --aot

or configure aot as the default compiler by adding it to your angular.json

"architect": {
  "serve": {
    "options": {
      "aot": true
    }
  }
}

and call ng serve.

The same can be done for build.

frido
  • 13,065
  • 5
  • 42
  • 56