Skip to content

Angular Language Service keeps crashing when using host and generic with host type-checking #63052

Closed

Description

@csvn

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

language-service

Is this a regression?

Yes

Description

When using typeCheckHostBindings in Angular compiler options, the Angular Language Service will crash when it encounters a Component/Directive that has a host property as well as a generic. Disabling typeCheckHostBindings is an easy way to work around the issue, but that's not ideal.

Generics without host, or host without generics both seem to work. It just seems to be unusable when they are both used at the same component.

Image

Reproduction

  1. Create a fresh Angular project

    $ npx @angular/cli@latest new --ssr=false --style=css --zoneless=false ng-20.1
  2. Update the App component so that it has a host property and a generic (App<T>)

    Show full app.ts
    import { Component, input, signal } from '@angular/core';
    import { RouterOutlet } from '@angular/router';
    
    @Component({
      selector: 'app-root',
      imports: [RouterOutlet],
      templateUrl: './app.html',
      styleUrl: './app.css',
      host: {
        '[class.show]': 'show()'
      }
    })
    export class App<T> {
      protected readonly title = signal('ng-20.1');
      readonly show = input<T>();
    }
  3. Do any editor action (find all references)

  4. Check "Output > Angular Language Service" for the error

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:55841
                throw new Error(`Assertion Error: expected ${dirRef.debugName} not to be generic.`);
                      ^

Error: Assertion Error: expected App not to be generic.
    at TcbNonGenericDirectiveTypeOp.execute (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:55841:23)
    at Scope.executeOp (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:57347:28)
    at Scope.render (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:57233:22)
    at renderBlockStatements (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:55445:39)
    at generateTypeCheckBlock (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:55430:29)
    at TypeCheckFile.addTypeCheckBlock (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:58267:24)
    at TypeCheckContextImpl.addDirective (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:58480:31)
    at ComponentDecoratorHandler.typeCheck (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:63994:17)
    at TraitCompiler.typeCheck (c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:43913:39)
    at c:\Users\<user>\.vscode\extensions\angular.ng-template-20.2.0\node_modules\@angular\language-service\bundles\language-service.js:60055:39

Reproduction link

https://stackblitz.com/edit/siflugxu?file=src%2Fmain.ts

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

Angular CLI: 20.1.5
Node: 24.4.1
Package Manager: npm 11.4.2
OS: win32 x64

Angular: 20.1.6
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2001.5
@angular-devkit/core         20.1.5
@angular-devkit/schematics   20.1.5
@angular/build               20.1.5
@angular/cli                 20.1.5
@schematics/angular          20.1.5
rxjs                         7.8.2
typescript                   5.8.3
zone.js                      0.15.1

Anything else?

No response

Activity

  1. csvn commented on Aug 7, 2025

    @csvn
    ContributorAuthor

    I can't find a way to create a new Stackblitz with Angular (is Stackblitz gone?), so I don't have a reproduction link currently.

  2. self-assigned this
    on Aug 7, 2025
  3. crisbeto commented on Aug 7, 2025

    @crisbeto
    Member

    Are you seeing this error only in the language service or does it also happen when you try to build the app?

  4. csvn commented on Aug 7, 2025

    @csvn
    ContributorAuthor

    Only the language service. I didn't see any issues during build or serve.

  5. csvn commented on Aug 7, 2025

    @csvn
    ContributorAuthor

    Just double checked, both ng build and ng serve both run without issues. It's just the Language Service that keeps crashing.

  6. csvn commented on Aug 7, 2025

    @csvn
    ContributorAuthor

    I don't know if this is platform specific, but I'm using VSCode v1.103.0 and v20.2.0 of the Angular.ng-template extension on WIndows.

  7. added a commit that references this issue on Aug 8, 2025
    5efc94e
  8. added a commit that references this issue on Aug 8, 2025
    4aa120a
  9. csvn commented on Aug 8, 2025

    @csvn
    ContributorAuthor

    Awesome, thanks for the quick work @crisbeto, @atscott & team! 🎉 💪

  10. added a commit that references this issue on Aug 8, 2025
    c77e519
  11. angular-automatic-lock-bot commented on Sep 8, 2025

    @angular-automatic-lock-bot

    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.

  12. locked and limited conversation to collaborators on Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions