From 377a484afce11fb27a881a80f00912a1690230a2 Mon Sep 17 00:00:00 2001 From: Julien Gautier Date: Tue, 26 May 2026 13:34:03 +0200 Subject: [PATCH] fix(structures): widen via String() in narrowing test to satisfy lint The narrowing test for `isStructureKind` had `const candidate: string = 'medico_social'`, which ESLint's `@typescript-eslint/no-inferrable-types` correctly flags as trivially-inferred. The naive fix - dropping the annotation - would let TypeScript infer the literal type `'medico_social'`, which is already a StructureKind subtype. The narrowing check would then be vacuous (TypeScript already knows the value is a kind, the runtime guard has nothing to prove). Fix: round-trip through `String()` to widen the literal to `string`. TypeScript infers `string` for `String(...)` return; no annotation needed; the narrowing test stays meaningful. CI lint target on portal-bff now passes 0 errors. The 13 remaining warnings (non-null assertions in principal-extractor.spec, unused underscored params in rate-limit.middleware, etc.) are pre-existing and not in scope for this fix. --- apps/portal-bff/src/structures/structure-kind.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/portal-bff/src/structures/structure-kind.spec.ts b/apps/portal-bff/src/structures/structure-kind.spec.ts index 55e21e9..6745e42 100644 --- a/apps/portal-bff/src/structures/structure-kind.spec.ts +++ b/apps/portal-bff/src/structures/structure-kind.spec.ts @@ -35,7 +35,10 @@ describe('isStructureKind', () => { }); it('narrows the type at the call site', () => { - const candidate: string = 'medico_social'; + // Round-trip through `String()` to widen the literal to `string`. + // Without this the inferred type is `'medico_social'`, already a + // StructureKind subtype — the narrowing check would be vacuous. + const candidate = String('medico_social'); if (!isStructureKind(candidate)) { throw new Error('unreachable — candidate is a known kind'); }