@dsivd/prestations-ng 19.2.0-beta.11 → 19.2.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/CONTRIBUTING.md +1 -1
- package/GOOD_PRACTICES.md +443 -396
- package/INTRODUCTION_ANGULAR_SIGNALS.md +150 -150
- package/UPGRADING_V19.md +50 -5
- package/fesm2022/dsivd-prestations-ng.mjs +4 -1
- package/fesm2022/dsivd-prestations-ng.mjs.map +1 -1
- package/package.json +1 -1
- package/dsivd-prestations-ng-19.2.0-beta.11.tgz +0 -0
package/UPGRADING_V19.md
CHANGED
|
@@ -1246,7 +1246,7 @@ In `front/src/`, remove the file `typings.d.ts` if it is still there.
|
|
|
1246
1246
|
{
|
|
1247
1247
|
"extends": "./tsconfig.json",
|
|
1248
1248
|
"compilerOptions": {
|
|
1249
|
-
"outDir": "
|
|
1249
|
+
"outDir": "./out-tsc/app",
|
|
1250
1250
|
"types": []
|
|
1251
1251
|
},
|
|
1252
1252
|
"include": ["src/**/*.ts"],
|
|
@@ -1448,12 +1448,45 @@ When using `IntelliJ`, you can run code inspection on your project to fix deprec
|
|
|
1448
1448
|
- In your `tsconfig.json` file, add `"strict": true` in `compilerOptions` and remove `alwaysStrict`, `noImplicitThis`, `strictBindCallApply` and `strictFunctionTypes` as they are already included in `strict` mode.
|
|
1449
1449
|
- In your `tsconfig.json` file, remove `useDefineForClassFields` from `compilerOptions`.
|
|
1450
1450
|
|
|
1451
|
-
|
|
1451
|
+
Without `useDefineForClassFields: false`, the class fields follow the standard semantics: they are initialized before
|
|
1452
|
+
the body of the constructor, so before the parameter properties, and a field declared again in a subclass overwrites
|
|
1453
|
+
the value set by the parent class. Two errors can appear:
|
|
1454
|
+
|
|
1455
|
+
- TS2729 (`Property 'x' is used before its initialization`): a field initializer uses a parameter property of the
|
|
1456
|
+
constructor. Use `inject()` in the initializer, or assign the field in the constructor. Don't move a
|
|
1457
|
+
`private readonly x = inject(X)` field above the public fields: the `@typescript-eslint/member-ordering` rule of
|
|
1458
|
+
`@dsivd/prestations-ng/eslint` wants the public fields first.
|
|
1459
|
+
|
|
1460
|
+
```diff
|
|
1461
|
+
- readonly items = toSignal(this.itemService.getItems(), { initialValue: [] });
|
|
1462
|
+
-
|
|
1463
|
+
- constructor(private readonly itemService: ItemService) {}
|
|
1464
|
+
+ readonly items = toSignal(inject(ItemService).getItems(), { initialValue: [] });
|
|
1465
|
+
```
|
|
1466
|
+
|
|
1467
|
+
```ts
|
|
1468
|
+
readonly items: Signal<Item[]>;
|
|
1469
|
+
|
|
1470
|
+
private readonly itemService = inject(ItemService);
|
|
1471
|
+
|
|
1472
|
+
constructor() {
|
|
1473
|
+
this.items = toSignal(this.itemService.getItems(), { initialValue: [] });
|
|
1474
|
+
}
|
|
1475
|
+
```
|
|
1476
|
+
|
|
1477
|
+
- TS2612 (`Property 'x' will overwrite the base property`): a subclass declares again a field of its parent class,
|
|
1478
|
+
e.g. to narrow its type. Add `declare` (`declare form: MyForm | null | undefined;`) or remove the declaration, but
|
|
1479
|
+
never add an initializer: it would overwrite the value set by the parent class.
|
|
1480
|
+
|
|
1481
|
+
Now fix your project until no more errors (unlike `tsc -b`, these commands write nothing):
|
|
1452
1482
|
|
|
1453
1483
|
```bash
|
|
1454
|
-
npx tsc -
|
|
1484
|
+
npx tsc -p tsconfig.app.json --noEmit
|
|
1485
|
+
npx tsc -p tsconfig.spec.json --noEmit
|
|
1455
1486
|
```
|
|
1456
1487
|
|
|
1488
|
+
`tsc` doesn't check the templates: the errors reported by `strictTemplates` appear when you build your application.
|
|
1489
|
+
|
|
1457
1490
|
and finally run the following commands to build, test and start your application:
|
|
1458
1491
|
|
|
1459
1492
|
```bash
|
|
@@ -1515,6 +1548,8 @@ The CommonJS dependencies of prestations-ng are now `"iban"` and `"dayjs"` (whic
|
|
|
1515
1548
|
"allowedCommonJsDependencies": ["iban", "dayjs"]
|
|
1516
1549
|
```
|
|
1517
1550
|
|
|
1551
|
+
Also remove the packages that are no longer installed (`npm ls <package>` lists nothing).
|
|
1552
|
+
|
|
1518
1553
|
### Zoneless (optional but recommended)
|
|
1519
1554
|
|
|
1520
1555
|
Since v19.2, prestations-ng does not need zone.js anymore: the state of its components is held by signals, which
|
|
@@ -1558,6 +1593,10 @@ then uninstall zone.js:
|
|
|
1558
1593
|
npm uninstall zone.js
|
|
1559
1594
|
```
|
|
1560
1595
|
|
|
1596
|
+
`zone.js` stays in your `package-lock.json` as an optional peer dependency of `@angular/core`: this is expected. Check
|
|
1597
|
+
instead that the build of your application no longer outputs a `polyfills` chunk (unless you still have other
|
|
1598
|
+
polyfills, e.g. `@angular/localize/init`).
|
|
1599
|
+
|
|
1561
1600
|
#### Check your components
|
|
1562
1601
|
|
|
1563
1602
|
Without zone.js, Angular refreshes a component only when it is notified that something changed:
|
|
@@ -1601,12 +1640,18 @@ Pay attention to:
|
|
|
1601
1640
|
ngOnInit(): void {
|
|
1602
1641
|
super.ngOnInit();
|
|
1603
1642
|
this.sessionInfoWithApplicationService.prefillForm((info) => {
|
|
1604
|
-
this.form
|
|
1605
|
-
|
|
1643
|
+
if (this.form) {
|
|
1644
|
+
this.form.email = info?.email ?? null;
|
|
1645
|
+
this.changeDetectorRef.markForCheck();
|
|
1646
|
+
}
|
|
1606
1647
|
});
|
|
1607
1648
|
}
|
|
1608
1649
|
```
|
|
1609
1650
|
|
|
1651
|
+
- the fields read by the template and set in `ngAfterViewInit()`, `ngAfterContentInit()` or `ngAfterViewChecked()`:
|
|
1652
|
+
derive them with `computed()` from `viewChild()` or `contentChild()` (see "Deriving a state from view queries"
|
|
1653
|
+
in [GOOD_PRACTICES.md](GOOD_PRACTICES.md)).
|
|
1654
|
+
|
|
1610
1655
|
- `NgZone`: `onStable`, `onMicrotaskEmpty` and `onUnstable` never emit without zone.js, and `run()` or
|
|
1611
1656
|
`runOutsideAngular()` are useless. To act on the rendered DOM (focus, scroll...), replace them, as well as the
|
|
1612
1657
|
`setTimeout()` waiting for the view, by `afterNextRender()`. `AbstractMenuPageComponent.ngZone` is deprecated.
|
|
@@ -3867,7 +3867,10 @@ class FoehnFeedbackNotificationComponent {
|
|
|
3867
3867
|
.post(`api/feedbacknotification/queryparams/${reference}`, fbu, {
|
|
3868
3868
|
responseType: 'text',
|
|
3869
3869
|
})
|
|
3870
|
-
.pipe(map((cryptedUrlParams) => `${feedBackFormBaseUrl}?q=${encodeURIComponent(cryptedUrlParams)}`))
|
|
3870
|
+
.pipe(map((cryptedUrlParams) => `${feedBackFormBaseUrl}?q=${encodeURIComponent(cryptedUrlParams)}`), catchError((e) => {
|
|
3871
|
+
console.error('Unable to get the feedback url, returning null', e);
|
|
3872
|
+
return of(null);
|
|
3873
|
+
}));
|
|
3871
3874
|
}
|
|
3872
3875
|
getCategory(sessionInfoData, etapeInfo) {
|
|
3873
3876
|
if (sessionInfoData?.categories) {
|