fix(admin): unbreak ci:check on PR2b (TS2454 + missing fr translation) #237
Reference in New Issue
Block a user
Delete Branch "fix/pr2b-build-errors"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Follow-up fix on #236 (ADR-0026 PR 2b). Two issues that
nx run-many -t buildexposed butnx run-many -t testmasked:user-scopes.service.ts— webpack's strict-mode build flaggedlet exists: booleanas "used before assigned". jest's--transpile-onlydoesn't enforce definite-assignment so it slipped through local checks.route.user-scopes.title— Angular's@angular/localizebuild target requires every$localizeID to have a target inmessages.fr.xlf. The route I added in #236 referenced the ID but I didn't add the trans-unit.What lands
apps/portal-bff/src/admin/user-scopes.service.tslet exists = falseinstead oflet exists: boolean. TheVALUE_BEARING_KINDS.has(kind)check earlier in the function does narrowkindsemantically, butSet.hasdoesn't propagate type narrowing the wayArray.includesor a custom type guard would. Initialising tofalseis the smallest fix; the nextif (!exists)still throws the friendly "does not match" message in the (unreachable-by-construction) fallback.apps/portal-admin/src/locale/messages.fr.xlf<trans-unit id="route.user-scopes.title">— FR targetPérimètres utilisateur — Administration APF Portal.Why these failed locally
--transpile-onlyso it skips definite-assignment analysis (and most type-checking). Webpack's production build runs fulltscand catches it.pnpm nx serve portal-admindoesn't run the localize pass; only--configuration=productiondoes. My localnx test portal-adminruns 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-adminwould have caught both pre-PR. Worth apnpm ci:check:fastshorthand 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.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.