Skip to content

Commit d2fd189

Browse files
chore: update to v22 of Angular/NgRx (#312)
* chore: npx nx migrate latest * chore: pnpm install --no-frozen-lockfile * pnpm exec nx migrate --run-migrations * chore: bump NgRx deps to v22 * chore: bump package's version + peer deps versions * chore: run `prettier --write ./**/*.{js,ts,json,html,scss,md}` * chore: update components with explicit `Eager` CD
1 parent aceb534 commit d2fd189

27 files changed

Lines changed: 7095 additions & 4053 deletions

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/.nx/cache
55
.angular
66
pnpm-lock.yaml
7+
8+
.nx/self-healing

apps/demo/src/app/app.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { LayoutModule } from '@angular/cdk/layout';
2-
import { provideHttpClient, withInterceptors } from '@angular/common/http';
2+
import {
3+
provideHttpClient,
4+
withInterceptors,
5+
withXhr,
6+
} from '@angular/common/http';
37
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
48
import { provideAnimations } from '@angular/platform-browser/animations';
59
import { provideRouter, withComponentInputBinding } from '@angular/router';
@@ -10,7 +14,7 @@ export const appConfig: ApplicationConfig = {
1014
providers: [
1115
provideRouter(appRoutes, withComponentInputBinding()),
1216
provideAnimations(),
13-
provideHttpClient(withInterceptors([memoryHttpInterceptor])),
17+
provideHttpClient(withXhr(), withInterceptors([memoryHttpInterceptor])),
1418
importProvidersFrom(LayoutModule),
1519
],
1620
};

apps/demo/src/app/events-sample/events-sample.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommonModule } from '@angular/common';
2-
import { Component, inject } from '@angular/core';
2+
import { Component, inject, signal } from '@angular/core';
33
import { FormsModule } from '@angular/forms';
44
import { MatButtonModule } from '@angular/material/button';
55
import { MatCardModule } from '@angular/material/card';
@@ -152,7 +152,7 @@ import { BookStore } from './book.store';
152152
export class EventsSampleComponent {
153153
readonly store = inject(BookStore);
154154
readonly dispatch = injectDispatch(bookEvents);
155-
filterText = '';
155+
filterText = signal('');
156156

157157
toggleStock(bookId: string, event: Event) {
158158
event.stopPropagation();

apps/demo/src/app/flight-search-data-service-simple/flight-search-simple.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { JsonPipe } from '@angular/common';
2-
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
2+
import { Component, inject } from '@angular/core';
33
import { FormsModule } from '@angular/forms';
44
import { MatButtonModule } from '@angular/material/button';
55
import { MatInputModule } from '@angular/material/input';
@@ -20,7 +20,6 @@ import { SimpleFlightBookingStore } from './flight-booking-simple.store';
2020
],
2121
selector: 'demo-flight-search',
2222
templateUrl: './flight-search-simple.component.html',
23-
changeDetection: ChangeDetectionStrategy.OnPush,
2423
})
2524
export class FlightSearchSimpleComponent {
2625
private store = inject(SimpleFlightBookingStore);

apps/demo/src/app/shared/flight-card.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@let selected = this.selected();
2+
@let item = this.item();
3+
14
<div class="card" [ngClass]="{ 'active-card': selected }">
25
<div class="card-header">
36
<h2 class="title">{{ item.from }} - {{ item.to }}</h2>
Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
import { CommonModule } from '@angular/common';
2-
import {
3-
ChangeDetectionStrategy,
4-
Component,
5-
EventEmitter,
6-
Input,
7-
Output,
8-
} from '@angular/core';
2+
import { Component, input, model } from '@angular/core';
93
import { RouterModule } from '@angular/router';
104
import { initFlight } from './flight';
115

126
@Component({
137
selector: 'demo-flight-card',
148
imports: [CommonModule, RouterModule],
159
templateUrl: './flight-card.component.html',
16-
changeDetection: ChangeDetectionStrategy.OnPush,
1710
})
1811
export class FlightCardComponent {
19-
@Input() item = initFlight;
20-
@Input() selected: boolean | undefined;
21-
@Output() selectedChange = new EventEmitter<boolean>();
12+
public readonly item = input(initFlight);
13+
public readonly selected = model.required<boolean>();
2214

23-
select() {
24-
this.selected = true;
25-
this.selectedChange.next(true);
15+
protected select() {
16+
this.selected.set(true);
2617
}
2718

28-
deselect() {
29-
this.selected = false;
30-
this.selectedChange.next(false);
19+
protected deselect() {
20+
this.selected.set(false);
3121
}
3222
}

apps/demo/src/app/todo-entity-resource/todo-entity-resource.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, computed, effect, inject } from '@angular/core';
1+
import { Component, computed, effect, inject, signal } from '@angular/core';
22
import { FormsModule } from '@angular/forms';
33
import { MatIcon } from '@angular/material/icon';
44
import { MatInputModule } from '@angular/material/input';
@@ -21,7 +21,7 @@ import { TodoEntityResourceStore } from './todo-entity-resource.store';
2121
})
2222
export class TodoEntityResourceComponent {
2323
protected readonly store = inject(TodoEntityResourceStore);
24-
protected newTitle = '';
24+
protected newTitle = signal('');
2525
protected readonly dataSource = new MatTableDataSource<{
2626
id: number;
2727
title: string;
@@ -43,11 +43,11 @@ export class TodoEntityResourceComponent {
4343
}
4444
trackById = (_: number, t: { id: number }) => t.id;
4545
add() {
46-
const title = this.newTitle.trim();
46+
const title = this.newTitle().trim();
4747
if (!title) return;
4848
const ids = this.store.ids() as Array<number>;
4949
const nextId = ids.length ? Math.max(...ids) + 1 : 1;
5050
this.store.addTodo({ id: nextId, title, completed: false });
51-
this.newTitle = '';
51+
this.newTitle.set('');
5252
}
5353
}

apps/demo/tsconfig.app.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@
66
},
77
"files": ["src/main.ts"],
88
"include": ["src/**/*.d.ts"],
9-
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
9+
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"],
10+
"angularCompilerOptions": {
11+
"extendedDiagnostics": {
12+
"checks": {
13+
"nullishCoalescingNotNullable": "suppress",
14+
"optionalChainNotNullable": "suppress"
15+
}
16+
}
17+
}
1018
}

apps/demo/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"noFallthroughCasesInSwitch": true,
1212
"module": "preserve",
1313
"moduleResolution": "bundler",
14-
"lib": ["dom", "es2022"]
14+
"lib": ["dom", "es2022"],
15+
"ignoreDeprecations": "6.0"
1516
},
1617
"files": [],
1718
"include": [],

apps/demo/tsconfig.spec.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,13 @@
1414
"src/**/*.test.ts",
1515
"src/**/*.spec.ts",
1616
"src/**/*.d.ts"
17-
]
17+
],
18+
"angularCompilerOptions": {
19+
"extendedDiagnostics": {
20+
"checks": {
21+
"nullishCoalescingNotNullable": "suppress",
22+
"optionalChainNotNullable": "suppress"
23+
}
24+
}
25+
}
1826
}

0 commit comments

Comments
 (0)