Repository: angular
Issue: TS-996002 makes finding errors difficult
Labels: hotlist: error messages,area: core,area: compiler,core: NgModule,P3,bug

### Which @angular/* package(s) are the source of the bug?

compiler

### Is this a regression?

No

### Description

[Sharing modules](https://angular.dev/guide/ngmodules/sharing) are very useful in large projects. But when the sharing module fails to compile because of an error within its `imports`, the console fills up with `TS-996002` for every component or module using the sharing module:

```bash
✘ [ERROR] TS-996002: 'FeatureCoreSharedModule' does not appear to be an NgModule class. [plugin angular-compiler]

    libs/features/account/src/child/child-feature.module.ts:23:4:
      23 │     FeatureCoreSharedModule,
         ╵     ~~~~~~~~~~~~~~~~~~~~~~~~~

  Is it missing an @NgModule annotation?

    libs/features/core/src/feature-core-shared.module.ts:151:13:
      151 │ export class FeatureCoreSharedModule {}
```

For very large projects, `TS-996002`-errors can fill the whole console, pushing the actual error outside of the console stdout. Small errors that would take a few seconds to fix can take incredibly long, since developers have to manually go through all `imports` of a sharing module manually to find the error.

### Please provide a link to a minimal reproduction of the bug

Repro: https://github.com/blidblid/57341-reproduction

### Steps:

1. Note that `src/app/children/h/index.ts` is empty, which causes an error in `ChildrenSharingModule`
2. `ng s`
3. The console is filled with `TS-996002` for every import of `ChildrenSharingModule`

Even though this is a small project, it still takes long time for a developer to figure out what's actually wrong.

### Steps to compare logs with a broken feature module:

1. Fix `src/app/children/h/index.ts`
2. Remove contents of `src/app/features/h/index.ts` instead
3. The console is now clear and concise with a single `TS-996002`.


### Please provide the exception or error you saw

```bash
✘ [ERROR] TS-996002: 'FeatureCoreSharedModule' does not appear to be an NgModule class. [plugin angular-compiler]

    libs/features/account/src/child/child-feature.module.ts:23:4:
      23 │     FeatureCoreSharedModule,
         ╵     ~~~~~~~~~~~~~~~~~~~~~~~~~

  Is it missing an @NgModule annotation?

    libs/features/core/src/feature-core-shared.module.ts:151:13:
      151 │ export class FeatureCoreSharedModule {}
```

### Please provide the environment you discovered this bug in (run `ng version`)

Angular CLI: 17.1.4
Node: 20.12.0
Package Manager: yarn 1.22.19
OS: darwin arm64

Angular: 17.1.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker

Package                              Version
--------------------------------------------------------------
@angular-devkit/architect            0.1701.4
@angular-devkit/build-angular        17.1.4
@angular-devkit/core                 17.1.4
@angular-devkit/schematics           17.1.4
@angular/cdk                         17.1.2
@angular/cli                         17.1.4
@angular/fire                        7.5.0
@angular/material                    17.1.2
@angular/material-date-fns-adapter   17.1.2
@angular/pwa                         17.1.4
@schematics/angular                  17.1.4
ng-packagr                           17.1.2
rxjs                                 7.8.1
typescript                           5.3.3
zone.js                              0.14.4

### Anything else?

_No response_