Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions adev-es/src/content/reference/extended-diagnostics/NG8021.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Defer Trigger Misconfiguration

This diagnostic detects unreachable or redundant triggers in `@defer` blocks.

```typescript

import {Component} from '@angular/core';

@Component({
template: `
@defer (on immediate; on timer(500ms)) {
<large-component />
}
`
})
class MyComponent {}
```

## What's wrong with that?

The diagnostic identifies several problematic patterns in defer trigger configuration that lead to:

- **Unnecessary code** that never affects behavior
- **Missed optimization opportunities** for better performance
- **Unreachable prefetch triggers** that will never execute

## Diagnostic warning cases

This diagnostic flags the following problematic patterns:

### `immediate` with prefetch triggers

**Bad — prefetch never runs**

```typescript
@Component({
template: `
@defer (on immediate; prefetch on idle) {
<my-cmp />
}
`
})
class MyComponent {}
```

**Good — remove redundant prefetch**

```typescript
@Component({
template: `
@defer (on immediate) {
<my-cmp />
}
`
})
class MyComponent {}
```

### Prefetch timer not earlier than main timer

**Bad — prefetch is later than main**

```typescript
@Component({
template: `
@defer (on timer(100ms); prefetch on timer(3000ms)) {
<my-cmp />
}
`
})
class MyComponent {}
```

**Bad — equal timing provides no benefit**

```typescript
@Component({
template: `
@defer (on timer(500ms); prefetch on timer(500ms)) {
<my-cmp />
}
`
})
class MyComponent {}
```

**Good — prefetch fires earlier**

```typescript
@Component({
template: `
@defer (on timer(1000ms); prefetch on timer(500ms)) {
<large-component />
}
`
})
class MyComponent {}
```

### Identical prefetch and main triggers

**Bad — identical viewport trigger**

```typescript
@Component({
template: `
@defer (on viewport; prefetch on viewport) {
<my-cmp />
}
`
})
class MyComponent {}
```

**Bad — identical interaction target**

```typescript
@Component({
template: `
<button #loadBtn>Load</button>
@defer (on interaction(loadBtn); prefetch on interaction(loadBtn)) {
<large-component />
}
`
})
class MyComponent {}
```

**Good — remove redundant prefetch**

```typescript
@Component({
template: `
<button #loadBtn>Load</button>
@defer (on interaction(loadBtn)) {
<large-component />
}
`
})
class MyComponent {}
```

**Good — use different targets for prefetch and main**

```typescript
@Component({
template: `
<div #hoverArea>Hover to prefetch</div>
<button #clickBtn>Click to load</button>
@defer (on interaction(clickBtn); prefetch on hover(hoverArea)) {
<large-component />
}
`
})
class MyComponent {}
```

## Configuration requirements

[`strictTemplates`](tools/cli/template-typecheck#strict-mode) must be enabled for any extended diagnostic to emit.
`deferTriggerMisconfiguration` has no additional requirements beyond `strictTemplates`.

## What if I can't avoid this?

This diagnostic can be disabled by editing the project's `tsconfig.json` file:

```json
{
"angularCompilerOptions": {
"extendedDiagnostics": {
"checks": {
"deferTriggerMisconfiguration": "suppress"
}
}
}
}
```

See [extended diagnostic configuration](extended-diagnostics#configuration) for more info.
54 changes: 27 additions & 27 deletions adev-es/src/content/reference/extended-diagnostics/NG8021.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Defer Trigger Misconfiguration
# Configuración incorrecta de disparadores de Defer

This diagnostic detects unreachable or redundant triggers in `@defer` blocks.
Este diagnóstico detecta disparadores inalcanzables o redundantes en bloques `@defer`.

```typescript

Expand All @@ -16,21 +16,21 @@ import {Component} from '@angular/core';
class MyComponent {}
```

## What's wrong with that?
## ¿Qué está mal con eso?

The diagnostic identifies several problematic patterns in defer trigger configuration that lead to:
El diagnóstico identifica varios patrones problemáticos en la configuración de disparadores de defer que conducen a:

- **Unnecessary code** that never affects behavior
- **Missed optimization opportunities** for better performance
- **Unreachable prefetch triggers** that will never execute
- **Código innecesario** que nunca afecta el comportamiento
- **Oportunidades de optimización perdidas** para un mejor rendimiento
- **Disparadores de precarga inalcanzables** que nunca se ejecutarán

## Diagnostic warning cases
## Casos de advertencia del diagnóstico

This diagnostic flags the following problematic patterns:
Este diagnóstico marca los siguientes patrones problemáticos:

### `immediate` with prefetch triggers
### `immediate` con disparadores de precarga

**Badprefetch never runs**
**Incorrectola precarga nunca se ejecuta**

```typescript
@Component({
Expand All @@ -43,7 +43,7 @@ This diagnostic flags the following problematic patterns:
class MyComponent {}
```

**Goodremove redundant prefetch**
**Correctoelimina la precarga redundante**

```typescript
@Component({
Expand All @@ -56,9 +56,9 @@ class MyComponent {}
class MyComponent {}
```

### Prefetch timer not earlier than main timer
### Temporizador de precarga no anterior al temporizador principal

**Badprefetch is later than main**
**Incorrectola precarga es posterior al principal**

```typescript
@Component({
Expand All @@ -71,7 +71,7 @@ class MyComponent {}
class MyComponent {}
```

**Badequal timing provides no benefit**
**Incorrectoel mismo tiempo no aporta ningún beneficio**

```typescript
@Component({
Expand All @@ -84,7 +84,7 @@ class MyComponent {}
class MyComponent {}
```

**Goodprefetch fires earlier**
**Correctola precarga se dispara antes**

```typescript
@Component({
Expand All @@ -97,9 +97,9 @@ class MyComponent {}
class MyComponent {}
```

### Identical prefetch and main triggers
### Disparadores de precarga y principal idénticos

**Badidentical viewport trigger**
**Incorrectodisparador de viewport idéntico**

```typescript
@Component({
Expand All @@ -112,7 +112,7 @@ class MyComponent {}
class MyComponent {}
```

**Badidentical interaction target**
**Incorrectoobjetivo de interacción idéntico**

```typescript
@Component({
Expand All @@ -126,7 +126,7 @@ class MyComponent {}
class MyComponent {}
```

**Goodremove redundant prefetch**
**Correctoelimina la precarga redundante**

```typescript
@Component({
Expand All @@ -140,7 +140,7 @@ class MyComponent {}
class MyComponent {}
```

**Gooduse different targets for prefetch and main**
**Correctousa objetivos diferentes para la precarga y el principal**

```typescript
@Component({
Expand All @@ -155,14 +155,14 @@ class MyComponent {}
class MyComponent {}
```

## Configuration requirements
## Requisitos de configuración

[`strictTemplates`](tools/cli/template-typecheck#strict-mode) must be enabled for any extended diagnostic to emit.
`deferTriggerMisconfiguration` has no additional requirements beyond `strictTemplates`.
[`strictTemplates`](tools/cli/template-typecheck#strict-mode) debe estar habilitado para que se emita cualquier diagnóstico extendido.
`deferTriggerMisconfiguration` no tiene requisitos adicionales más allá de `strictTemplates`.

## What if I can't avoid this?
## ¿Qué pasa si no puedo evitar esto?

This diagnostic can be disabled by editing the project's `tsconfig.json` file:
Este diagnóstico puede deshabilitarse editando el archivo `tsconfig.json` del proyecto:

```json
{
Expand All @@ -176,4 +176,4 @@ This diagnostic can be disabled by editing the project's `tsconfig.json` file:
}
```

See [extended diagnostic configuration](extended-diagnostics#configuration) for more info.
Consulta la [configuración de diagnósticos extendidos](extended-diagnostics#configuración) para más información.
48 changes: 48 additions & 0 deletions adev-es/src/content/reference/extended-diagnostics/NG8101.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Invalid Banana-in-Box

This diagnostic detects a backwards "banana-in-box" syntax for [two-way bindings](guide/templates/two-way-binding).

```

<user-viewer ([user])="loggedInUser" />
```

## What's wrong with that?

As it stands, `([var])` is actually an [event binding](guide/templates/event-listeners) with the name `[var]`.
The author likely intended this as a two-way binding to a variable named `var` but, as written, this binding has no effect.

## What should I do instead?

Fix the typo.
As the name suggests, the banana `(` should go _inside_ the box `[]`.
In this case:

```

<user-viewer [(user)]="loggedInUser" />
```

## Configuration requirements

[`strictTemplates`](tools/cli/template-typecheck#strict-mode) must be enabled for any extended diagnostic to emit.
`invalidBananaInBox` has no additional requirements beyond `strictTemplates`.

## What if I can't avoid this?

This diagnostic can be disabled by editing the project's `tsconfig.json` file:

```json

{
"angularCompilerOptions": {
"extendedDiagnostics": {
"checks": {
"invalidBananaInBox": "suppress"
}
}
}
}
```

See [extended diagnostic configuration](extended-diagnostics#configuration) for more info.
Loading