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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to disable "NG3: The containing function or module body is too large for control flow analysis. [plugin angular-compiler]" rule #54688

Open
mitat-koyuncu-work opened this issue Mar 4, 2024 · 6 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler needs reproduction This issue needs a reproduction in order for the team to investigate further
Milestone

Comments

@mitat-koyuncu-work
Copy link

Which @angular/* package(s) are relevant/related to the feature request?

common, compiler-cli, compiler

Description

Recently our team upgraded Angular version from 16 to 17. But we couldn't start the project because of "NG3: The containing function or module body is too large for control flow analysis. [plugin angular-compiler]" error. Not all components have this problem.

Proposed solution

Ability to disable the "NG3: The containing function or module body is too large for control flow analysis. [plugin angular-compiler]"

Alternatives considered

We considered refactoring our code but it is simply too time consuming.

@pkozlowski-opensource pkozlowski-opensource added the area: compiler Issues related to `ngc`, Angular's template compiler label Mar 4, 2024
@ngbot ngbot bot added this to the needsTriage milestone Mar 4, 2024
@alxhub alxhub added the needs reproduction This issue needs a reproduction in order for the team to investigate further label Mar 5, 2024
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 5, 2024
@alxhub
Copy link
Member

alxhub commented Mar 5, 2024

That error is a TypeScript compiler error, not an Angular error specifically (the fact that it shows up as NG3 is a little surprising...). It's TypeScript complaining that one of the functions in the code is too big/branchy to be analyzed for type narrowing.

Probably the code in question is not one of your own functions, but a component template (which gets translated to a function for type-checking). If a template has too many branches, it can trigger this error.

We'll need a working reproduction to further diagnose the problem and determine if it's due to an excessively large template or perhaps a bug that's causing excessive branching in the type-check block.

@mitat-koyuncu-work
Copy link
Author

The component that throws error is around 5000 lines and html template file is over 3000 lines . I don't think i can just copy the file because of dependencies it would fail but i will try to create a component without that dependencies with same error.

When updating to Angular 17 we migrated to new build system via "ng update @angular/cli --name use-application-builder" command. I don't know if error has any connection with this change.

I did a research about error message and found it related to TS2563 typescript error. But i didn't find a way to disable it through tsconfig.json file.

Thanks

@mitat-koyuncu-work
Copy link
Author

I created a stackblitz about this error here: link

I noticed in stackblitz i am getting a different error but i think it is related with NG3 error:

✘ [ERROR] Maximum call stack size exceeded [plugin angular-compiler]

  This error came from the "onStart" callback registered here:

    node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:81:18:
      81 │             build.onStart(async () => {
         ╵                   ~~~~~~~

    at setup (/home/projects/stackblitz-starters-sl7l8v/node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:81:19)
    at async handlePlugins (/home/projects/stackblitz-starters-sl7l8v/node_modules/esbuild/lib/main.js:1330:9)

I hope this helps.

@byturkak
Copy link

byturkak commented Mar 7, 2024

I have the same problem and don't know why either.. Do you solve it?

@alxhub
Copy link
Member

alxhub commented Mar 12, 2024

We would still need a working reproduction of this issue in order to investigate.

@mitat-koyuncu-work
Copy link
Author

@alxhub I created a stackblitz here: link

I know stackblitz doesn't have same error but in vscode same code gives ng3 error. If this is not enough let me know what i can provide to you.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: compiler Issues related to `ngc`, Angular's template compiler needs reproduction This issue needs a reproduction in order for the team to investigate further
Projects
None yet
Development

No branches or pull requests

4 participants