Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(language-service): resolve module specifier for a directive … #62100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ivanwonder
Copy link
Contributor

@ivanwonder ivanwonder commented Jun 17, 2025

…exported by multiple different files

When providing the code action for the directive that is exported by multiple modules in different files, the directive must save all the TS completion entry data for every module to compute the module specifier.

When providing a completion item, because the LS only supports displaying one directive at a time, the first one will be picked.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot bot added the area: language-service Issues related to Angular's VS Code language service label Jun 17, 2025
@ngbot ngbot bot added this to the Backlog milestone Jun 17, 2025
@ivanwonder ivanwonder marked this pull request as ready for review June 17, 2025 14:32
@pullapprove pullapprove bot requested a review from mmalerba June 17, 2025 14:33
importOn.getSourceFile(),
potentialImport.symbolName,
declarationName,
directiveModuleSpecifier?.moduleSpecifier ?? potentialImport.moduleSpecifier,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's my mistake; the potentialImport can include multiple different module specifiers that export the directive and cannot be overridden directly. The code moves to the PotentialDirectiveModuleSpecifierResolverImpl.

@mmalerba mmalerba requested review from atscott and removed request for mmalerba June 17, 2025 16:00
@atscott atscott added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed action: merge The PR is ready for merge by the caretaker labels Jun 18, 2025
@atscott atscott force-pushed the support-mul-completion-entry-data branch from bf83885 to 36a8919 Compare June 18, 2025 22:28
…exported by multiple different files

When providing the code action for the directive that is exported by multiple modules
in different files, the directive must save all the TS completion entry data
for every module to compute the module specifier.

When providing a completion item, because the LS only supports displaying one directive
at a time, the first one will be picked.
@atscott atscott force-pushed the support-mul-completion-entry-data branch from 36a8919 to 8e754a9 Compare June 20, 2025 21:12
@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Jun 20, 2025
Comment on lines +750 to +757
/**
* Try to compute the module specifier after applying the paths from tsconfig or package.json export rules.
*
* Try to reuse the module specifier if the import in the `importOn` can export the `toImport` node.
*
* If a module specifier cannot be resolved, return undefined, and the Angular compiler will apply its own rules.
*
* There is one exception here. For example
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just comment out the main change in comparison to the previous version here. Even if an exception occurs, it will revert to the Angular compiler and keep the same behavior as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: language-service Issues related to Angular's VS Code language service target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants