Language Service doesn't support directive composition API
See original GitHub issueWhich @angular/* package(s) are the source of the bug?
language-service
Is this a regression?
No
Description
Let say I have a directive like this:
import { Directive, HostBinding, Input } from '@angular/core';
@Directive({
standalone: true,
selector: '[appBgColor]'
})
export class BgColorDirective {
@HostBinding('style.display') display = 'inline-block';
@Input() @HostBinding('style.background-color') bgColor = 'yellow';
}
In the component, I want to use directive composition API including the inputs
import { Component } from '@angular/core';
import { BgColorDirective } from '../bg-color.directive';
@Component({
selector: 'app-my-comp',
templateUrl: './my-comp.component.html',
styleUrls: ['./my-comp.component.scss'],
hostDirectives: [
{
directive: BgColorDirective,
inputs: ['bgColor']
}
]
})
export class MyCompComponent { }
And the usage of component
<app-my-comp [bgColor]="'red'"></app-my-comp>
After compile, it works fine. But in VSCode, I got this error:

I think this is about the language service issue.
Please provide a link to a minimal reproduction of the bug
https://github.com/wellwind/ng-directive-composition-api-language-service-bug-demo
Please provide the exception or error you saw
It should has no error in VSCode.
Please provide the environment you discovered this bug in (run ng version
)
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 15.0.0
Node: 16.17.0
Package Manager: npm 8.15.0
OS: darwin arm64
Angular: 15.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1500.0
@angular-devkit/build-angular 15.0.0
@angular-devkit/core 15.0.0
@angular-devkit/schematics 15.0.0
@schematics/angular 15.0.0
rxjs 7.5.7
typescript 4.8.4
Anything else?
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Directive composition API - Angular
The directive composition API lets you apply directives to a component's host element from within the component TypeScript class.
Read more >Variables created in the template always have type any #1155
The types shown by Angular Language Service reflect what you've ... Typechecking of context doesn't work with custom directives #1158.
Read more >Introduction to Angular Language Service | by Enea Jahollari
A language service is a program that you feed your code, and it will report you… ... So, we won't get any support...
Read more >Angular Language Service not working with VS Code ...
4 Answers 4 · Go to the extensions tab on VS Code · Click the gear icon on the right side of the...
Read more >Composition API FAQ - Vue.js
Composition API is a set of APIs that allows us to author Vue components using ... on function composition, Composition API is NOT...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Are you using the latest version of the extension? The latest version of the extension is required because it bundles the Angular compiler and host directives were not supported pre-v15.
Note: I downloaded your project everything appeared to be working.
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.