You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prefer components over directives for auto-import in template suggestions of element tags #68522
Which @angular/* package(s) are relevant/related to the feature request?
language-service
Description
When automatically importing items into a component while typing in the template, components and directives are suggested in alphabetical order. I think it would be better to prefer a component import when possible.
Imagine a component library that provides a ButtonComponent and an AddButtonDirective to apply a preset to the button.
When the language service suggests an automatic import, it prefers AddButtonDirective because it comes first alphabetically.
<!-- this should suggest ButtonComponent over AddButtonDirective --><app-button
Proposed solution
The language service should suggest the component over the directive in this case.
Alternatives considered
Alternative is to leave the element selector off of all directive selectors, but this is not always ideal or possible, as some directives might require a specific component host.
Fwiw, you'll get better autocompletion with the quick fix feature:
I believe quick fix works because the component is the only thing that matches the element tag. Quick fix can also suggest multiple actions, so if the attribute is added, it'll be listed in the fixes.
Activity
tuobi2 commentedon May 2, 2026
JeanMeche commentedon May 2, 2026
This looks like to be WebStorm which uses its own language service. Please report the feature request directly to them.
eblocha commentedon May 2, 2026
@JeanMeche This is in vscode
tuobi2 commentedon May 2, 2026
JeanMeche commentedon May 2, 2026
Fwiw, you'll get better autocompletion with the quick fix feature:
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
eblocha commentedon May 2, 2026
I believe quick fix works because the component is the only thing that matches the element tag. Quick fix can also suggest multiple actions, so if the attribute is added, it'll be listed in the fixes.
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
tuobi2 commentedon May 2, 2026
refactor(language-service): Improve directive completion