fix(structures): widen via String() in narrowing test to satisfy lint #231
Reference in New Issue
Block a user
Delete Branch "fix/structure-kind-spec-lint"
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
One-line lint fix in apps/portal-bff/src/structures/structure-kind.spec.ts — the narrowing test failed CI lint with
@typescript-eslint/no-inferrable-typesonconst candidate: string = 'medico_social'.The naive fix (drop the annotation) would make the test vacuous: TypeScript would infer the literal type
'medico_social', which is already aStructureKindsubtype, so the runtime guardisStructureKindwould have nothing to prove. Fix instead: widen viaString('medico_social')— the inferred return type isstring, the narrowing check stays meaningful, the linter is happy.What lands
apps/portal-bff/src/structures/structure-kind.spec.tsconst candidate: string = 'medico_social'→const candidate = String('medico_social'). 3-line comment explains whyString()rather than dropping the annotation.Test plan
pnpm exec nx lint portal-bff—0 errors, 13 warnings(warnings all pre-existing in unrelated files).pnpm exec prettier --checkclean.pnpm ci:checkpasses on this PR.String('literal')pattern reads like over-engineering).Notes for the reviewer
principal-extractor.spec.ts, unused underscored params inrate-limit.middleware.ts, one stale eslint-disable indownstream-token-cache.service.spec.ts) are outside the scope of this PR — none of them block CI today, and folding them in would muddle the diff. Worth a separatechore(bff): sweep lint warningsPR if/when those become noisy.String()over anas stringcast? Both would work, butString()is a real runtime operation (returns a freshstring) —as stringis type-system-only. The runtime call has a tiny side-effect (and the inferred return type really ISstring, not the literal), so the narrowing test stays semantically real.@typescript-eslint/no-inferrable-typesis set toerrorseverity in the workspace config; my narrowing test was just the first case to trip it.