Repository navigation
Closed
Description
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.
Reproduction
-
Create a fresh Angular project
$ npx @angular/cli@latest new --ssr=false --style=css --zoneless=false ng-20.1
-
Update the
Appcomponent so that it has ahostproperty and a generic (App<T>)Show full
app.tsimport { 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>(); }
-
Do any editor action (find all references)
-
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
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
csvn commentedon Aug 7, 2025
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.
crisbeto commentedon Aug 7, 2025
Are you seeing this error only in the language service or does it also happen when you try to build the app?
csvn commentedon Aug 7, 2025
Only the language service. I didn't see any issues during
buildorserve.csvn commentedon Aug 7, 2025
Just double checked, both
ng buildandng serveboth run without issues. It's just the Language Service that keeps crashing.csvn commentedon Aug 7, 2025
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-templateextension on WIndows.fix(compiler-cli): error when type checking host bindings of generic …
fix(compiler-cli): error when type checking host bindings of generic …
csvn commentedon Aug 8, 2025
Awesome, thanks for the quick work @crisbeto, @atscott & team! 🎉 💪
fix(compiler-cli): error when type checking host bindings of generic …
angular-automatic-lock-bot commentedon Sep 8, 2025
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.