From ef74a1bb4deee40fe89f60e444850d4e7f1c235d Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 3 Apr 2026 18:27:38 -0400 Subject: [PATCH] add type predicates to .filter() in sqlUtils for strict TypeScript (#8709) The discriminated union type from values.map() wasn't being narrowed by .filter((info) => !info.raw), causing info.argNum to be typed as number | undefined instead of number. Co-authored-by: Claude Opus 4.6 (1M context) --- typescript-client/sqlUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript-client/sqlUtils.ts b/typescript-client/sqlUtils.ts index 696e2975b9..eef46c50bc 100644 --- a/typescript-client/sqlUtils.ts +++ b/typescript-client/sqlUtils.ts @@ -171,7 +171,7 @@ function buildSqlTemplateFunction(provider: SqlProvider): SqlTemplateFunction { // Arg declarations (SQL comments consumed by the executor) let argDecls = valueInfos - .filter((info) => !info.raw) + .filter((info): info is Extract<(typeof valueInfos)[number], { raw: false }> => !info.raw) .map((info) => { let argType = parseTypeAnnotation( @@ -211,7 +211,7 @@ function buildSqlTemplateFunction(provider: SqlProvider): SqlTemplateFunction { const args = { ...Object.fromEntries( valueInfos - .filter((info) => !info.raw) + .filter((info): info is Extract<(typeof valueInfos)[number], { raw: false }> => !info.raw) .map((info) => [`arg${info.argNum}`, info.value]) ), ...provider.extraArgs,