Language Service doesn't support directive composition API

This issue has been created since 2022-11-17.

Which @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:

image

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

atscott wrote this answer on 2022-11-17

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.

wellwind wrote this answer on 2022-11-17

I didn't notice the extension version, but it seems updated automatically, now I'm using v15.0.1 and all works fine. Thanks :)

atscott wrote this answer on 2022-11-17

@wellwind We did find some issues while investigating this. All inputs from the directive will be available in autocompletion (even if they're not listed in the hostDirective inputs). Also, host directives on other directives aren't showing up in completions (only for components)

crisbeto wrote this answer on 2022-11-17

I'll reopen this to investigate the issues Andrew mentioned.

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-12-01
Star Count 85220
Watcher Count 3042
Fork Count 22607
Issue Count 1316

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
fix: typo in the exercise title 1 2022-11-10 2022-11-17
Screen flickers on 1920 × 980px screen 2 2022-10-06 2022-11-17
beforeDelete and afterDelete hooks are not working 2 2022-07-02 2022-11-19
Add documentation for writing output plugins 0 2020-11-08 2022-11-19
reduce warnings in test suite 2 2022-02-18 2022-11-19
Allow SQL file paths for cohort and label queries 1 2022-01-07 2022-11-19
add scorecard type models for baselines 0 2022-01-13 2022-11-19
Use string datatype for all bias attributes in dataframe sent to aequitas 0 2021-11-30 2022-11-19
How can we render different sets of cluster with different colors? 7 2020-07-20 2022-09-18
Can we use this on expo production build? 6 2020-07-20 2022-10-23
Trainer Signal Lost between TX16sMK2 & Zorro - Throttle goes above 100% 9 2022-10-31 2022-11-18
Исправить опечатки в тексте подсказки 10 2021-12-30 2022-10-08
[studio-ui] Remove publishing status indicator from dashboards 0 2022-04-12 2022-11-12
Copy-DbaLogin hangs when database not present on destination server 1 2022-08-31 2022-11-30
Allow to disable unknown repositories 0 2020-06-17 2022-10-14
egpu doesn't work 1 2021-11-17 2021-12-23
Tap sensibility thrown off 2 2021-08-10 2022-10-22
remove unavailable media server 5 2021-11-30 2022-10-11
Analog headphones don't work 1 2021-07-26 2022-11-14
MoneroKon 2022 Planning Meeting: Saturday 9th April 2022 @ 17:00 UTC 1 2022-04-04 2022-11-28
`Time` seems to be a private struct 1 2022-06-09 2022-11-21
Add a retry counter 0 2021-02-04 2022-01-03
[Feature request] Add method on file to retrieve the blob of the transformed image 6 2021-06-20 2022-09-29
Error when running 'Hello_world' on U50 6 2021-12-01 2022-11-18
After an update the traybar pinned status is lost 1 2022-08-14 2022-11-27
Hidden status for articles 13 2016-05-28 2022-10-28
Create database with multi_select doesn't work 3 2022-08-05 2022-11-23
NetworkInterfaceAvailable waiter doesn't retry when facing InvalidNetworkInterfaceID.NotFound 1 2022-07-11 2022-11-15
[1.0 Release] List of expiring deprecations 1 2021-08-11 2022-10-07
Options for new blitters in Unicode 15+? 1 2022-06-28 2022-11-14
Python API confusion 0 2022-07-01 2022-11-14
[Question] circuitbreaker.Client() 开启熔断后如何在方法中实现降级 1 2022-04-20 2022-10-27
"Bug"/Feature request: Multicurrency incomplete for product buying price 6 2018-09-24 2022-10-10
Add unit test for names.go 2 2021-11-24 2022-11-29
Developer vote "?" counted as 0 in average calculation 6 2021-08-31 2022-11-10
Issue subscriber action failed 3 2022-01-19 2022-07-07
[BUG] - HideMutedCategories 1 2022-09-07 2022-10-30
Request: Add support for custom vertex shaders 5 2022-07-20 2022-08-30
java.lang.ExceptionInInitializerError caused by NPE in DriverInfo static initializer 4 2021-01-15 2022-11-17
[windows] upstream connection failed to logs.eu-west-2.amazonaws.com 6 2022-01-25 2022-08-31
tail input custom path not adding metadata 2 2022-01-25 2022-09-30
Unsupported State Format Version - terraform-json 2 2021-12-30 2022-11-24
Use environment variables in the path of external helm repos 1 2022-03-04 2022-09-30
please support more example 7 2020-09-11 2022-11-19
打包之后apk安装失败,报代码缺失 1 2021-12-07 2022-01-08
Unable to ignore or add custom projects 0 2021-11-23 2022-11-10
feat: Authorizing guest access to embedded dashboards 2 2021-12-15 2022-01-27
Sagemaker Transform Job fails if there are job with Same name 9 2022-03-02 2022-09-29
TypeError when creating a SourceMapGenerator from a SourceMapConsumer of an index map 3 2018-06-12 2022-11-17
Create Windows Node Pool 3 2021-05-05 2022-11-22