Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev server error is present when template error is fixed #39147

Closed
dereklin opened this issue Oct 6, 2020 · 3 comments
Closed

Dev server error is present when template error is fixed #39147

dereklin opened this issue Oct 6, 2020 · 3 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq3: high P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Milestone

Comments

@dereklin
Copy link

dereklin commented Oct 6, 2020

The issue is caused by package @angular/....

"@angular/animations": "~10.1.4",
"@angular/common": "~10.1.4",
"@angular/compiler": "~10.1.4",
"@angular/core": "~10.1.4",
"@angular/forms": "~10.1.4",
"@angular/platform-browser": "~10.1.4",
"@angular/platform-browser-dynamic": "~10.1.4",
"@angular/router": "~10.1.4",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"

Description

Dev server error is present when template error is fixed

🔬 Minimal Reproduction

install the latest version of @angular/cli

I am using

"@angular/cli": "~10.1.4",

create a brand new app like

ng new my-new-app

In app.component.html, copy and paste the following line inside of the main content div:

<h1 [style.color]="'red'">Hello World!</h1>

Change the first double quote to single quote to cause the template error. Then change it back to double quote to fix it.

In the terminal, these errors are shown:

    ERROR in src/app/app.module.ts:9:5 - error NG6001: The class 'AppComponent' is listed in the declarations of the NgModule 'AppModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.
    
    9     AppComponent
          ~~~~~~~~~~~~
    
      src/app/app.component.ts:8:14
        8 export class AppComponent {
                       ~~~~~~~~~~~~
        'AppComponent' is declared here.
    src/app/app.component.html:417:25 - error NG8002: Can't bind to 'ngSwitch' since it isn't a known property of 'div'.
    
    417   <div class="terminal" [ngSwitch]="selection.value">
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/app.component.ts:5:16
        5   templateUrl: './app.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component AppComponent.
    src/app/app.component.html:535:1 - error NG8001: 'router-outlet' is not a known element:
    1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
    2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    
    535 <router-outlet></router-outlet>
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/app.component.ts:5:16
        5   templateUrl: './app.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component AppComponent.

You can read more about issue submission guidelines here:

🌍 Your Environment

It's a brand new angular app as of 10/6/2020:

"dependencies": {
"@angular/animations": "~10.1.4",
"@angular/common": "~10.1.4",
"@angular/compiler": "~10.1.4",
"@angular/core": "~10.1.4",
"@angular/forms": "~10.1.4",
"@angular/platform-browser": "~10.1.4",
"@angular/platform-browser-dynamic": "~10.1.4",
"@angular/router": "~10.1.4",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1001.4",
"@angular/cli": "~10.1.4",
"@angular/compiler-cli": "~10.1.4",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}

@petebacondarwin petebacondarwin added area: compiler Issues related to `ngc`, Angular's template compiler type: bug/fix labels Oct 7, 2020
@ngbot ngbot bot modified the milestone: needsTriage Oct 7, 2020
@JoostK
Copy link
Member

JoostK commented Oct 17, 2020

The issue here is that template parse errors result in the whole component being invalid, causing the NgModule declaration to also be flagged as invalid. This causes the implicit dependency from app.module.ts to app.component.html not to be registered, such that fixing the template does not invalidate the captured state for app.module.ts that still contains the error.

@JoostK JoostK added the P4 A relatively minor issue that is not relevant to core functions label Oct 17, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Oct 17, 2020
@JoostK JoostK added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed P4 A relatively minor issue that is not relevant to core functions labels Nov 19, 2020
@JoostK
Copy link
Member

JoostK commented Dec 5, 2020

This has been fixed in #39967 and will be part of the 11.0.4 release, somewhere next week.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq3: high P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
Development

No branches or pull requests

4 participants