Skip to content

[vite] Internal server error: ASSERTION ERROR: Expected [Text|Element|Container|ElementContainer|Projection|IcuContainer] but got LetDeclaration. #57160

@hungtcs

Description

@hungtcs

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

This is my template, if the first sentence in @for is an @let, an error is reported.

    @let count = _routeData().count;
    @let records = _routeData().data;

    @for (record of records; track $index; let last = $last) {
      @let author = record.userInfo;
      @let article = record.article;
      @let statistic = record.articleStatistic;
      <section class="article">
        <div class="author">

If insert an empty ng-container before @let, the error goes away

    @let count = _routeData().count;
    @let records = _routeData().data;

    @for (record of records; track $index; let last = $last) {
      <ng-container></ng-container>
      @let author = record.userInfo;
      @let article = record.article;
      @let statistic = record.articleStatistic;
      <section class="article">
        <div class="author">

I can't reproduce this error in a minimal project at the moment, and I haven't yet found out why it occurs.

Please provide a link to a minimal reproduction of the bug

I am currently unable to reproduce this issue in other projects

Please provide the exception or error you saw

12:05:45 AM [vite] Internal server error: ASSERTION ERROR: Expected [Text|Element|Container|ElementContainer|Projection|IcuContainer] but got LetDeclaration.
      at throwError (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:2861:9)
      at assertTNodeType (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:5686:5)
      at getFirstNativeNode (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:8689:18)
      at getBeforeNodeForView (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:8747:14)
      at getFirstNativeNode (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:8698:14)
      at calcPathForNode (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:11287:24)
      at appendSerializedNodePath (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:24335:33)
      at serializeLView (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:24429:11)
      at annotateHostElementForHydration (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:24457:17)
      at serializeLView (/home/hungtcs/Workspaces/@hungtcs/irho/.angular/cache/18.1.2/vite/deps_ssr/chunk-WUB3NTET.js:24417:9) (x2)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 18.1.2
Node: 22.3.0
Package Manager: pnpm 9.1.4
OS: linux x64

Angular: 18.1.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, material, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.1
@angular-devkit/build-angular   18.1.2
@angular-devkit/core            18.1.1
@angular-devkit/schematics      18.1.1
@schematics/angular             18.1.1
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.8

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions