fix(admin): unbreak ci:check on PR2b (TS2454 + missing fr translation) #237

Merged
julien merged 1 commits from fix/pr2b-build-errors into main 2026-05-26 16:18:12 +02:00
Owner

Summary

Follow-up fix on #236 (ADR-0026 PR 2b). Two issues that nx run-many -t build exposed but nx run-many -t test masked:

  1. TS2454 in user-scopes.service.ts — webpack's strict-mode build flagged let exists: boolean as "used before assigned". jest's --transpile-only doesn't enforce definite-assignment so it slipped through local checks.
  2. Missing FR translation for route.user-scopes.title — Angular's @angular/localize build target requires every $localize ID to have a target in messages.fr.xlf. The route I added in #236 referenced the ID but I didn't add the trans-unit.

What lands

File Change
apps/portal-bff/src/admin/user-scopes.service.ts Initialise let exists = false instead of let exists: boolean. The VALUE_BEARING_KINDS.has(kind) check earlier in the function does narrow kind semantically, but Set.has doesn't propagate type narrowing the way Array.includes or a custom type guard would. Initialising to false is the smallest fix; the next if (!exists) still throws the friendly "does not match" message in the (unreachable-by-construction) fallback.
apps/portal-admin/src/locale/messages.fr.xlf New <trans-unit id="route.user-scopes.title"> — FR target Périmètres utilisateur — Administration APF Portal.

Why these failed locally

  • TS2454: jest runs with --transpile-only so it skips definite-assignment analysis (and most type-checking). Webpack's production build runs full tsc and catches it.
  • Missing translation: the dev server pnpm nx serve portal-admin doesn't run the localize pass; only --configuration=production does. My local nx test portal-admin runs in JIT mode against the source locale, so the missing FR target slid through.

For the future: pnpm nx run-many -t build --projects=portal-bff,portal-admin would have caught both pre-PR. Worth a pnpm ci:check:fast shorthand that runs a subset of the CI gates locally before push — but that's a separate PR.

Test plan

  • pnpm exec nx run-many -t build --projects=portal-bff,portal-admin — both pass.
  • No application logic changed in either fix (initialise vs declare; add a missing translation row).
  • CI green on this PR.
## Summary Follow-up fix on [#236](https://git.unespace.com/julien/apf_portal/pulls/236) (ADR-0026 PR 2b). Two issues that `nx run-many -t build` exposed but `nx run-many -t test` masked: 1. **TS2454 in `user-scopes.service.ts`** — webpack's strict-mode build flagged `let exists: boolean` as "used before assigned". jest's `--transpile-only` doesn't enforce definite-assignment so it slipped through local checks. 2. **Missing FR translation** for `route.user-scopes.title` — Angular's `@angular/localize` build target requires every `$localize` ID to have a target in `messages.fr.xlf`. The route I added in #236 referenced the ID but I didn't add the trans-unit. ## What lands | File | Change | | --- | --- | | `apps/portal-bff/src/admin/user-scopes.service.ts` | Initialise `let exists = false` instead of `let exists: boolean`. The `VALUE_BEARING_KINDS.has(kind)` check earlier in the function does narrow `kind` semantically, but `Set.has` doesn't propagate type narrowing the way `Array.includes` or a custom type guard would. Initialising to `false` is the smallest fix; the next `if (!exists)` still throws the friendly "does not match" message in the (unreachable-by-construction) fallback. | | `apps/portal-admin/src/locale/messages.fr.xlf` | New `<trans-unit id="route.user-scopes.title">` — FR target `Périmètres utilisateur — Administration APF Portal`. | ## Why these failed locally - **TS2454**: jest runs with `--transpile-only` so it skips definite-assignment analysis (and most type-checking). Webpack's production build runs full `tsc` and catches it. - **Missing translation**: the dev server `pnpm nx serve portal-admin` doesn't run the localize pass; only `--configuration=production` does. My local `nx test portal-admin` runs in JIT mode against the source locale, so the missing FR target slid through. For the future: `pnpm nx run-many -t build --projects=portal-bff,portal-admin` would have caught both pre-PR. Worth a `pnpm ci:check:fast` shorthand that runs a subset of the CI gates locally before push — but that's a separate PR. ## Test plan - [x] `pnpm exec nx run-many -t build --projects=portal-bff,portal-admin` — both pass. - [x] No application logic changed in either fix (initialise vs declare; add a missing translation row). - [ ] CI green on this PR.
julien added 1 commit 2026-05-26 16:17:58 +02:00
fix(admin): unbreak ci:check on PR2b (TS2454 + missing fr translation)
CI / commits (pull_request) Successful in 4m57s
CI / scan (pull_request) Successful in 4m59s
CI / check (pull_request) Successful in 6m46s
CI / a11y (pull_request) Successful in 2m6s
CI / perf (pull_request) Successful in 9m5s
adb4d35274
webpack-cli build --node-env=production failed on two issues that
ts-jest's --transpile-only didn't surface:

1. portal-bff TS2454 in user-scopes.service.ts:221 — TypeScript
   couldn't see the switch on `kind` as exhaustive, so `let exists:
   boolean` was flagged as "used before assigned". The narrowing on
   VALUE_BEARING_KINDS.has(kind) doesn't propagate through Set.has
   (only Array.includes / type-guards do). Initialise `exists =
   false` so it's definitely assigned regardless of switch path;
   semantically safe — a non-value-bearing kind that reaches the
   switch (shouldn't happen by construction) leaves exists=false and
   the next `if (!exists)` throws the same friendly "does not match"
   message.

2. portal-admin missing translation: route.user-scopes.title was
   declared in app.routes.ts but never added to messages.fr.xlf.
   @angular/localize build target requires every $localize id to
   have a target in the active locale. Added the trans-unit for the
   FR locale ("Périmètres utilisateur — Administration APF Portal").

Local: nx run-many -t build --projects=portal-bff,portal-admin
passes on both.
julien merged commit 8bc36b460a into main 2026-05-26 16:18:12 +02:00
julien deleted branch fix/pr2b-build-errors 2026-05-26 16:18:16 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: julien/apf_portal#237