Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Ivy errors emit a lot of diagnostics for unrelated files #33849

Closed
filipesilva opened this issue Nov 15, 2019 · 3 comments
Closed

Some Ivy errors emit a lot of diagnostics for unrelated files #33849

filipesilva opened this issue Nov 15, 2019 · 3 comments

Comments

@filipesilva
Copy link
Member

@filipesilva filipesilva commented Nov 15, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/core, or maybe compiler-cli

Is this a regression?

Not sure

Description

Some Ivy errors have a simple enough cause, but emit many diagnostics for unrelated things.

The repro below will emit ~4000 lines of errors for instance, whereas only the first error matters.

ERROR in ../node_modules/angular2-promise-buttons/dist/angular2-promise-buttons.module.d.ts:4:48 - error TS-996005: Angular2PromiseButtonModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
4     static forRoot(config?: PromiseBtnConfig): ModuleWithProviders;
                                                 ~~~~~~~~~~~~~~~~~~~
app/ui/ui.module.ts:253:14 - error TS-996002: Appears in the NgModule.imports of SnackModule, but could not be resolved to an NgModule class
253 export class UiModule {
                 ~~~~~~~~
app/ui/ui.module.ts:253:14 - error TS-996002: Appears in the NgModule.imports of BannerModule, but could not be resolved to an NgModule class
253 export class UiModule {
                 ~~~~~~~~
app/core/snack/snack.module.ts:20:14 - error TS-996002: Appears in the NgModule.imports of CoreModule, but itself has errors
20 export class SnackModule {
                ~~~~~~~~~~~
app/core/banner/banner.module.ts:18:14 - error TS-996002: Appears in the NgModule.imports of CoreModule, but itself has errors

# 4000 lines later

app/features/metric/evaluation-sheet/evaluation-sheet.component.html:15:23 - error TS-998003: No directive found with exportAs 'ngModel'.
15         <input #mood="ngModel"
                         ~~~~~~~
  app/features/metric/evaluation-sheet/evaluation-sheet.component.ts:27:16
    27   templateUrl: './evaluation-sheet.component.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component EvaluationSheetComponent.
app/features/metric/evaluation-sheet/evaluation-sheet.component.html:33:31 - error TS-998003: No directive found with exportAs 'ngModel'.
33         <input #productivity="ngModel"
                                 ~~~~~~~
  app/features/metric/evaluation-sheet/evaluation-sheet.component.ts:27:16
    27   templateUrl: './evaluation-sheet.component.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component EvaluationSheetComponent.
app/features/metric/evaluation-sheet/evaluation-sheet.component.html:10:13 - error TS-998003: No directive found with exportAs 'ngForm'.
10   <form #f="ngForm"
               ~~~~~~
  app/features/metric/evaluation-sheet/evaluation-sheet.component.ts:27:16
    27   templateUrl: './evaluation-sheet.component.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component EvaluationSheetComponent.
app/features/note/note/note.component.html:33:22 - error TS-998003: No directive found with exportAs 'matMenu'.
33     <mat-menu #menu="matMenu">
                        ~~~~~~~
  app/features/note/note/note.component.ts:10:16
    10   templateUrl: './note.component.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component NoteComponent.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

馃敩 Minimal Reproduction

git clone https://github.com/filipesilva/super-productivity
cd super-productivity
git checkout update-9
yarn
yarn buildFrontendDev

If you want to capture the full log, use yarn buildFrontendDev &> log.txt instead.

馃敟 Exception or Error

This seems to be the real error:


ERROR in ../node_modules/angular2-promise-buttons/dist/angular2-promise-buttons.module.d.ts:4:48 - error TS-996005: Angular2PromiseButtonModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
4     static forRoot(config?: PromiseBtnConfig): ModuleWithProviders;
                                                 ~~~~~~~~~~~~~~~~~~~

It can be addressed by adding the following ngcc.config.js and removing node_modules:

module.exports = {
  packages: {
    'angular2-promise-buttons': {
      entryPoints: { '.': { override: {module: undefined } } }
    }
  }
};

馃實 Your Environment

Angular Version:


Angular CLI: 9.0.0-rc.2
Node: 10.16.0
OS: win32 x64
Angular: 9.0.0-rc.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.900.0-rc.2
@angular-devkit/build-angular      0.900.0-rc.2
@angular-devkit/build-optimizer    0.900.0-rc.2
@angular-devkit/build-webpack      0.900.0-rc.2
@angular-devkit/core               9.0.0-rc.2
@angular-devkit/schematics         9.0.0-rc.2
@angular/cdk                       9.0.0-rc.1
@angular/material                  9.0.0-rc.1
@angular/material-moment-adapter   9.0.0-rc.1
@ngtools/webpack                   9.0.0-rc.2
@schematics/angular                8.3.8
@schematics/update                 0.900.0-rc.2
rxjs                               6.5.3
typescript                         3.6.4
webpack                            4.41.2

Anything else relevant?

cc @petebacondarwin @alxhub

@filipesilva

This comment has been minimized.

Copy link
Member Author

@filipesilva filipesilva commented Nov 15, 2019

@JoostK

This comment has been minimized.

Copy link
Member

@JoostK JoostK commented Dec 16, 2019

This was mostly introduced in bfc26bc, where a template is type-checked even if nog NgModule scope information is available. This is the case when an error exists in the NgModule, or any transitive NgModule.

alxhub added a commit to alxhub/angular that referenced this issue Dec 17, 2019
Previously, ngtsc would perform scope analysis (which directives/pipes are
available inside a component's template) and template type-checking of that
template as separate steps. If a component's scope was somehow invalid (e.g.
its NgModule imported something which wasn't another NgModule), the
component was treated as not having a scope. This meant that during template
type-checking, errors would be produced for any invalid expressions/usage of
other components that should have been in the scope.

This commit changes ngtsc to skip template type-checking of a component if
its scope is erroneous (as opposed to not present in the first place). Thus,
users aren't overwhelmed with diagnostic errors for the template and are
only informed of the root cause of the problem: an invalid NgModule scope.

Fixes angular#33849
alxhub added a commit to alxhub/angular that referenced this issue Dec 17, 2019
Previously, ngtsc would perform scope analysis (which directives/pipes are
available inside a component's template) and template type-checking of that
template as separate steps. If a component's scope was somehow invalid (e.g.
its NgModule imported something which wasn't another NgModule), the
component was treated as not having a scope. This meant that during template
type-checking, errors would be produced for any invalid expressions/usage of
other components that should have been in the scope.

This commit changes ngtsc to skip template type-checking of a component if
its scope is erroneous (as opposed to not present in the first place). Thus,
users aren't overwhelmed with diagnostic errors for the template and are
only informed of the root cause of the problem: an invalid NgModule scope.

Fixes angular#33849
alxhub added a commit to alxhub/angular that referenced this issue Dec 17, 2019
Previously, ngtsc would perform scope analysis (which directives/pipes are
available inside a component's template) and template type-checking of that
template as separate steps. If a component's scope was somehow invalid (e.g.
its NgModule imported something which wasn't another NgModule), the
component was treated as not having a scope. This meant that during template
type-checking, errors would be produced for any invalid expressions/usage of
other components that should have been in the scope.

This commit changes ngtsc to skip template type-checking of a component if
its scope is erroneous (as opposed to not present in the first place). Thus,
users aren't overwhelmed with diagnostic errors for the template and are
only informed of the root cause of the problem: an invalid NgModule scope.

Fixes angular#33849
alxhub added a commit to alxhub/angular that referenced this issue Dec 18, 2019
Previously, ngtsc would perform scope analysis (which directives/pipes are
available inside a component's template) and template type-checking of that
template as separate steps. If a component's scope was somehow invalid (e.g.
its NgModule imported something which wasn't another NgModule), the
component was treated as not having a scope. This meant that during template
type-checking, errors would be produced for any invalid expressions/usage of
other components that should have been in the scope.

This commit changes ngtsc to skip template type-checking of a component if
its scope is erroneous (as opposed to not present in the first place). Thus,
users aren't overwhelmed with diagnostic errors for the template and are
only informed of the root cause of the problem: an invalid NgModule scope.

Fixes angular#33849
alxhub added a commit to alxhub/angular that referenced this issue Dec 18, 2019
Previously, ngtsc would perform scope analysis (which directives/pipes are
available inside a component's template) and template type-checking of that
template as separate steps. If a component's scope was somehow invalid (e.g.
its NgModule imported something which wasn't another NgModule), the
component was treated as not having a scope. This meant that during template
type-checking, errors would be produced for any invalid expressions/usage of
other components that should have been in the scope.

This commit changes ngtsc to skip template type-checking of a component if
its scope is erroneous (as opposed to not present in the first place). Thus,
users aren't overwhelmed with diagnostic errors for the template and are
only informed of the root cause of the problem: an invalid NgModule scope.

Fixes angular#33849
alxhub added a commit to alxhub/angular that referenced this issue Dec 18, 2019
Previously, ngtsc would perform scope analysis (which directives/pipes are
available inside a component's template) and template type-checking of that
template as separate steps. If a component's scope was somehow invalid (e.g.
its NgModule imported something which wasn't another NgModule), the
component was treated as not having a scope. This meant that during template
type-checking, errors would be produced for any invalid expressions/usage of
other components that should have been in the scope.

This commit changes ngtsc to skip template type-checking of a component if
its scope is erroneous (as opposed to not present in the first place). Thus,
users aren't overwhelmed with diagnostic errors for the template and are
only informed of the root cause of the problem: an invalid NgModule scope.

Fixes angular#33849
kara added a commit that referenced this issue Dec 18, 2019
鈥34460)

Previously, ngtsc would perform scope analysis (which directives/pipes are
available inside a component's template) and template type-checking of that
template as separate steps. If a component's scope was somehow invalid (e.g.
its NgModule imported something which wasn't another NgModule), the
component was treated as not having a scope. This meant that during template
type-checking, errors would be produced for any invalid expressions/usage of
other components that should have been in the scope.

This commit changes ngtsc to skip template type-checking of a component if
its scope is erroneous (as opposed to not present in the first place). Thus,
users aren't overwhelmed with diagnostic errors for the template and are
only informed of the root cause of the problem: an invalid NgModule scope.

Fixes #33849

PR Close #34460
@kara kara closed this in 498a2ff Dec 18, 2019
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Jan 18, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can鈥檛 perform that action at this time.