-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Closed as duplicate of#55883
Labels
P4A relatively minor issue that is not relevant to core functionsA relatively minor issue that is not relevant to core functionsarea: coreIssues related to the framework runtimeIssues related to the framework runtimebugcore: reactivityWork related to fine-grained reactivity in the core frameworkWork related to fine-grained reactivity in the core frameworkcross-cutting: signals
Milestone
Description
Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
@for (breadcrumb of breadcrumbs(); track breadcrumb.name; let i = $index) {
<div class="breadcrumb">
@if (breadcrumb.linkPath) {
<a class="breadcrumb--link" [routerLink]="[breadcrumb.linkPath]"> {{ breadcrumb.name }}</a>
} @else {
<div class="breadcrumb--disabled">
{{ breadcrumb.name }}
</div>
}
@if **(i < breadcrumbs.length - 1)** {
<inm-icon [name]="'ChevronRight'" [size]="'x-small'"></inm-icon>
}
</div>
}
There currently are no lint warnings for i < breadcrumbs.length - 1
, my workaround ended up being:
@if (breadcrumbs()?.length; as breadCrumbsLength) {
@if (breadcrumbs(); as breadcrumbs) {
<div class="breadcrumb-ct">
@for (breadcrumb of breadcrumbs; track breadcrumb.name; let i = $index) {
<div class="breadcrumb">
@if (breadcrumb.linkPath) {
<a class="breadcrumb--link" [routerLink]="[breadcrumb.linkPath]"> {{ breadcrumb.name }}</a>
} @else {
<div class="breadcrumb--disabled">
{{ breadcrumb.name }}
</div>
}
@if (i < breadCrumbsLength - 1) {
<inm-icon [name]="'ChevronRight'" [size]="'x-small'"></inm-icon>
}
</div>
}
</div>
}
}
As directly using i < breadcrumbs()?.length - 1
receives a linting error of object undefined, even if it's nested within an if statement here:
@if (breadcrumbs() && breadcrumbs()?.length) {
<div class="breadcrumb-ct">
@for (breadcrumb of breadcrumbs(); track breadcrumb.name; let i = $index) {
<div class="breadcrumb">
@if (breadcrumb.linkPath) {
<a class="breadcrumb--link" [routerLink]="[breadcrumb.linkPath]"> {{ breadcrumb.name }}</a>
} @else {
<div class="breadcrumb--disabled">
{{ breadcrumb.name }}
</div>
}
@if (i < breadcrumbs()?.length - 1) {
<inm-icon [name]="'ChevronRight'" [size]="'x-small'"></inm-icon>
}
</div>
}
</div>
}
Proposed solution
To still have linting errors if invoking signals within nested @if and @for statenents.
Alternatives considered
n/a
SergeyBarskiyTyler
Metadata
Metadata
Assignees
Labels
P4A relatively minor issue that is not relevant to core functionsA relatively minor issue that is not relevant to core functionsarea: coreIssues related to the framework runtimeIssues related to the framework runtimebugcore: reactivityWork related to fine-grained reactivity in the core frameworkWork related to fine-grained reactivity in the core frameworkcross-cutting: signals