From adb4d35274445e6eb18e00d84e47ab42fa656f94 Mon Sep 17 00:00:00 2001 From: Julien Gautier Date: Tue, 26 May 2026 16:16:15 +0200 Subject: [PATCH] fix(admin): unbreak ci:check on PR2b (TS2454 + missing fr translation) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- apps/portal-admin/src/locale/messages.fr.xlf | 4 ++++ apps/portal-bff/src/admin/user-scopes.service.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/portal-admin/src/locale/messages.fr.xlf b/apps/portal-admin/src/locale/messages.fr.xlf index 07ce70e..ea3fc4a 100644 --- a/apps/portal-admin/src/locale/messages.fr.xlf +++ b/apps/portal-admin/src/locale/messages.fr.xlf @@ -21,6 +21,10 @@ Users — APF Portal Admin Utilisateurs — Administration APF Portal + + User scopes — APF Portal Admin + Périmètres utilisateur — Administration APF Portal + Profile — APF Portal Admin Profil — Administration APF Portal diff --git a/apps/portal-bff/src/admin/user-scopes.service.ts b/apps/portal-bff/src/admin/user-scopes.service.ts index 1a9a8ac..8f5b965 100644 --- a/apps/portal-bff/src/admin/user-scopes.service.ts +++ b/apps/portal-bff/src/admin/user-scopes.service.ts @@ -194,7 +194,15 @@ export class UserScopesService { // ADR-0026 PR 1's "no FK on UserScope.value" rationale lets the // value persist even after the target is decommissioned, so we // validate only at the write path. - let exists: boolean; + // + // Initialise `exists = false` so TypeScript sees it as definitely + // assigned regardless of how the switch lands (the type-system + // can't see that `VALUE_BEARING_KINDS.has` already narrowed + // `kind` to the three branches). If somehow a non-value-bearing + // kind reached this code, the false default makes the next `if` + // throw with the same friendly "does not match" message — safe + // by construction. + let exists = false; switch (kind) { case 'etablissement': exists = -- 2.30.2