angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.98k forks source link

"ng serve" requires restart when template error is fixed #25912

Closed psarno closed 1 year ago

psarno commented 1 year ago

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

Yes

Description

If we change a component to a self-closing tag after another error has occured during compilation, it refuses to pick up the changes to the self-closing tag.

I don't know what area this is in, I chose "compiler" because that seemed the closest.

Example:

You call the wrong method in a component:

<some-component (onClick)="doThis($event)"></some-component>

You have not declared doThis(event), and save the HTML.

The compilation runs, and fails, due to the method not being implemented.

You realize this was supposed to call "doSomething", and then return to the component to make your changes. At the same time, you realize it can use Angular 16's new self-closing tags:

<some-component (onClick)="doSomething($event)" />

You save this. The compiler will still error out, stating now that:

X [ERROR] NG9: Property 'doThis' does not exist on type 'SomeCompnent'. [plugin angular-compiler]

Nowhere in the code does it now reference the "doThis" mistake. Everything is saved.

But it won't compile anymore. It requires stopping the "ng serve" and re-running it. Then it works fine.

Please provide the exception or error you saw

X [ERROR] NG9: Property 'doThis' does not exist on type 'SomeCompnent'. [plugin angular-compiler]

Note "doThis" does not exist in the HTML anymore. The file has been saved. When the compiler runs again, it complains about this. The HTML now contains doSomething(), the correct call. It is seeing the older version.

Please provide the environment you discovered this bug in (run ng version)

@angular-devkit/architect       0.1602.0
@angular-devkit/build-angular   16.2.0
@angular-devkit/core            16.2.0
@angular-devkit/schematics      16.2.0
@angular/cdk                    16.2.1
@angular/cli                    16.2.0
@schematics/angular             16.2.0
rxjs                            7.8.1
typescript                      5.0.4
zone.js                         0.13.1

Anything else?

Nope.

angular-automatic-lock-bot[bot] commented 1 year ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.