8000 feat(compiler-cli): detect missing structural directive imports by manbearwiz · Pull Request #59443 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

feat(compiler-cli): detect missing structural directive imports #59443

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

Closed

Conversation

manbearwiz
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

Issue Number: #37322

Currently, the compiler will warn about missing directive imports if they are one of the "known" structural directives from the CommonModule or use regular binding syntax. This extends that to include custom, user-defined, structural directives. Currently, missing an import for these custom structural directives just fails silently which is a pain point when doing standalone migrations.

What is the new behavior?

The compiler will now warn on missing custom structural directives.

Does this PR introduce a breaking change?

  • Yes
  • No

I made minimal changes and left existing logic in order to ensure the changes are not breaking. I am definitely open to taking another approach, adding more test cases, etc.

@pullapprove pullapprove bot requested a review from devversion January 9, 2025 07:02
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Jan 9, 2025
Copy link
Member
@devversion devversion left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR.

The diagnostic is named control flow, but might be fine. Also adding @thePunderWoman as the original author IIRC

@devversion devversion added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jan 9, 2025
@manbearwiz
Copy link
Contributor Author

The diagnostic is named control flow, but might be fine.

Yeah that was one of the things I was unsure about. Would it be better as a separate diagnostic? Would renaming this diagnostic be considered a breaking change?

@thePunderWoman
Copy link
Contributor

@manbearwiz Since this extended diagnostic is specifically about control flow, this seems out of scope to me. I think it would be better to have a separate optional template diagnostic for this since it doesn't apply to everyone. What do you think?

@kirjs kirjs added the area: compiler Issues related to `ngc`, Angular's template compiler label Jan 9, 2025
@ngbot ngbot bot added this to the Backlog milestone Jan 9, 2025
@manbearwiz
Copy link
Contributor Author
manbearwiz commented Jan 9, 2025

That works for me. I'll update it to be a separate diagnostic. Any other suggestions while I'm in there? This will definitely touch a lot more files

@angular-robot angular-robot bot removed the area: compiler Issues related to `ngc`, Angular's template compiler label Jan 9, 2025
@ngbot ngbot bot removed this from the Backlog milestone Jan 9, 2025
@manbearwiz manbearwiz force-pushed the check-missing-structural-directives branch 2 times, most recently from f0b2991 to 9cdc812 Compare January 9, 2025 20:25
@kirjs kirjs added the area: compiler Issues related to `ngc`, Angular's template compiler label Jan 9, 2025
@ngbot ngbot bot added this to the Backlog milestone Jan 9, 2025
@manbearwiz manbearwiz changed the title feat(compiler-cli): detect missing structural directive imports in standalone components feat(compiler-cli): detect missing structural directive imports Jan 9, 2025
@thePunderWoman thePunderWoman added area: compiler-cli area: compiler Issues related to `ngc`, Angular's template compiler target: rc This PR is targeted for the next release-candidate and removed area: compiler Issues related to `ngc`, Angular's template compiler area: compiler-cli labels Jan 10, 2025
Copy link
Contributor
@thePunderWoman thePunderWoman left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@thePunderWoman thePunderWoman added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 10, 2025
@thePunderWoman
Copy link
Contributor

@manbearwiz It looks like you have legitimate test failures. Can you take a look?

@thePunderWoman thePunderWoman added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: presubmit The PR is in need of a google3 presubmit labels Jan 10, 2025
@JeanMeche JeanMeche force-pushed the check-missing-structural-directives branch 3 times, most recently from ee7a298 to c46f119 Compare April 27, 2025 13:11
@JeanMeche JeanMeche force-pushed the check-missing-structural-directives branch from c46f119 to 8e5faa2 Compare April 27, 2025 13:38
@thePunderWoman thePunderWoman removed their request for review April 28, 2025 08:34
@JeanMeche
Copy link
Member
JeanMeche commented Apr 28, 2025

G3 has been cleaned up. We'll go through a re-review after the recent changes.

@JeanMeche JeanMeche added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: blocked labels Apr 28, 2025
@JeanMeche JeanMeche force-pushed the check-missing-structural-directives branch 2 times, most recently from a6f82c3 to 17216d5 Compare April 28, 2025 23:01
@JeanMeche JeanMeche force-pushed the check-missing-structural-directives branch from 17216d5 to c76c88b Compare April 28, 2025 23:43
@JeanMeche JeanMeche removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Apr 29, 2025
@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Apr 29, 2025
@ngbot
Copy link
ngbot bot commented Apr 29, 2025

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google-internal-tests" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@JeanMeche JeanMeche added target: major This PR is targeted for the next major release and removed target: minor This PR is targeted for the next minor release labels Apr 29, 2025
@JeanMeche
Copy link
Member

Passing TGP, the broken target got fixed in between.

@mmalerba
Copy link
Contributor

This PR was merged into the repository by commit c889382.

The changes were merged into the following branches: main

@mmalerba mmalerba closed this in c889382 Apr 29, 2025
@JoostK
Copy link
Member
JoostK commented Apr 29, 2025

@manbearwiz Thanks for your effort into this PR! 💯

@manbearwiz
Copy link
Contributor Author
manbearwiz commented Apr 30, 2025

Of course! Glad it got in. Thanks @JeanMeche for taking it the rest of the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: global presubmit The PR is in need of a google3 global presubmit action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler compiler: extended diagnostics detected: feature PR contains a feature commit PullApprove: disable requires: TGP This PR requires a passing TGP before merging is allowed target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0