Skip to content

Language Service doesn't support directive composition API #48102

@wellwind

Description

@wellwind

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions