fix(compiler-cli): avoid recursive scope lookups for invalid NgModule imports#67750
Open
anchmelev wants to merge 1 commit intoangular:mainfrom
Open
fix(compiler-cli): avoid recursive scope lookups for invalid NgModule imports#67750anchmelev wants to merge 1 commit intoangular:mainfrom
anchmelev wants to merge 1 commit intoangular:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
… imports Producing the "not standalone" diagnostic for a declaration that is simultaneously listed in an NgModule's declarations and imports can ask for the component scope while that NgModule is still resolving. This re-enters local scope computation and can overflow the stack in tooling such as the language service. Return null for in-progress module scope lookups so the diagnostic falls back to the generic message instead of recursing. Fixes angular#65040
c387181 to
4f60dd7
Compare
Author
|
Hi @kirjs, just a gentle follow-up on this PR in case it got buried. |
JeanMeche
reviewed
Mar 24, 2026
| ` | ||
| import {Component, NgModule} from '@angular/core'; | ||
|
|
||
| @Component({template: ''}) |
Member
There was a problem hiding this comment.
That doesn't look right, the component is standalone by default.
Standalone components can't be declared in NgModules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
When a non-standalone component is accidentally left in both
declarationsandimportsof the sameNgModule, Angular computes the "not standalone"diagnostic while the module scope is still resolving. That diagnostic asks for
the component scope, re-enters the same scope computation, and can overflow the
stack. In the language service this surfaces as repeated server crashes.
Issue Number: #65040
What is the new behavior?
LocalModuleScopeRegistry.getScopeForComponent()now returnsnullwhen thedeclaring
NgModuleis still in progress, allowing the existing diagnostic tofall back to its generic message instead of recursively recomputing the module
scope.
A regression test covers the case where the same non-standalone component is
present in both
declarationsandimports.Does this PR introduce a breaking change?
Other information
Fixes #65040
Verified with:
pnpm bazel test //packages/compiler-cli/test/ngtsc:ngtsc --test_filter="*should not recurse when a non-standalone component is both declared and imported*"