@dsivd/prestations-ng 19.2.0-beta.12 → 19.2.0-beta.14

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/UPGRADING_V19.md CHANGED
@@ -1448,6 +1448,36 @@ 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
+ 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
+
1451
1481
  Now fix your project until no more errors (unlike `tsc -b`, these commands write nothing):
1452
1482
 
1453
1483
  ```bash
@@ -1563,7 +1593,7 @@ then uninstall zone.js:
1563
1593
  npm uninstall zone.js
1564
1594
  ```
1565
1595
 
1566
- `zone.js` stays in your `package-lock.json` as an optional peer dependency of `@angular/core`: this is expected. Check
1596
+ `zone.js` can stay in your `package-lock.json` as an optional peer dependency of `@angular/core`: this is expected. Check
1567
1597
  instead that the build of your application no longer outputs a `polyfills` chunk (unless you still have other
1568
1598
  polyfills, e.g. `@angular/localize/init`).
1569
1599
 
@@ -1618,6 +1648,10 @@ Pay attention to:
1618
1648
  }
1619
1649
  ```
1620
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
+
1621
1655
  - `NgZone`: `onStable`, `onMicrotaskEmpty` and `onUnstable` never emit without zone.js, and `run()` or
1622
1656
  `runOutsideAngular()` are useless. To act on the rendered DOM (focus, scroll...), replace them, as well as the
1623
1657
  `setTimeout()` waiting for the view, by `afterNextRender()`. `AbstractMenuPageComponent.ngZone` is deprecated.
@@ -1637,7 +1671,9 @@ Pay attention to:
1637
1671
  (`ExpressionChangedAfterItHasBeenCheckedError`). Fix the component (signal, `markForCheck()`) rather than the
1638
1672
  test.
1639
1673
  - `await fixture.whenStable()` waits for the change detection and for the pending tasks of the application
1640
- (e.g. the debounced `userInput` of the prestations-ng inputs), not for the timers.
1674
+ (e.g. the debounced `userInput` of the prestations-ng inputs), not for the timers, nor for the HTTP requests of a
1675
+ spec: `provideHttpClientTesting()` keeps them pending until the test answers them. Answer them first with
1676
+ `HttpTestingController` (`expectOne(...).flush(...)`), then `await fixture.whenStable()`.
1641
1677
 
1642
1678
  ### Last but not least, check if your application is working!!!
1643
1679
 
package/package.json CHANGED
@@ -39,7 +39,7 @@
39
39
  "ng-update": {
40
40
  "migrations": "./schematics/migration-collection.json"
41
41
  },
42
- "version": "19.2.0-beta.12",
42
+ "version": "19.2.0-beta.14",
43
43
  "module": "fesm2022/dsivd-prestations-ng.mjs",
44
44
  "typings": "types/dsivd-prestations-ng.d.ts",
45
45
  "exports": {