Why Angular JIT Compiler Mode is not catching template error

186 views Asked by At

I am running a simple application in angular 12.2.0

app.component.ts file:

import { Component} from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent  {
  
  appName = 'test-app';
  
}

app.component.html:

<p>{{appNameIncorrect}}</p>

Notice that I have mis-spelled appName to appNameIncorrect.

When I run ng serve. by default it has AOT mode. it properly prints an error in terminal that Property 'appNameIncorrect' does not exist on type 'AppComponent'.

Then I tried to set aot flag to false in angular.json file, I expected that application will be compiled correctly in linux terminal which I run ng serve but it will give same error as above in browser console. But that is not happening. Neither ng serve command output threw error nor browser reported any error.

Why is the case? JIT compiler should report an error in browser because in JIT mode, code gets compiled in runtime that is in Browser. I am curious to know why? Is there any compiler rule in angular which gives such result? I am using chrome as browser.

0

There are 0 answers