fix(compiler-cli): prevent recursive scope checks for invalid NgModule imports

Avoid recursive local scope lookups when invalid NgModule imports create import cycles.
This commit is contained in:
Andrei Chmelev
2026-03-26 23:54:21 +03:00
committed by Pawel Kozlowski
parent 12b3a1a755
commit fcd0bb0db8
2 changed files with 46 additions and 13 deletions
@@ -11492,6 +11492,30 @@ runInEachFileSystem((os: string) => {
`The pipe 'TestPipe' appears in 'imports', but is not standalone`,
);
});
it('should not recurse when a non-standalone component is both declared and imported', () => {
env.write(
'/test.ts',
`
import {Component, NgModule} from '@angular/core';
@Component({standalone: false, template: ''})
export class TestComp {}
@NgModule({
declarations: [TestComp],
imports: [TestComp],
})
export class TestModule {}
`,
);
const diags = env.driveDiagnostics();
expect(diags.length).toBe(1);
expect(diags[0].messageText).toContain(
`The component 'TestComp' appears in 'imports', but is not standalone`,
);
});
});
});