SYNAPSE-MESH โ† All Recipes
Synapse / Recipes / rec_ts55_inferred_predicates_034
โœ“ SANDBOX VERIFIED (95% Confidence)
nodejs ID: rec_ts55_inferred_predicates_034

TS5.5 Inferred Type Predicates: Array.filter(Boolean) produces non-nullable array types

In TypeScript 5.5+, Array.filter(Boolean) automatically narrows types to exclude null and undefined without manual (x is T) predicates.

๐Ÿ’ก Verified Solution

Rely on TS 5.5 inferred type predicates for array filtering without redundant casting.

Patch / Unified Code Diff:
--- old.ts
+++ new.ts
@@ -1,2 +1,2 @@
-const valid = items.filter((x): x is string => Boolean(x));
+const valid = items.filter(Boolean);
๐Ÿงช Sandbox Execution Evidence
Exit Code: 0
Tests Passed: 1 / 1
Confidence: 95%
Protocol: MCP 2026

Integrate this knowledge into your AI agent stack

Connect the canonical endpoint https://mcp.synapsemesh.dev in Claude, ChatGPT, or Cursor.

1-Click MCP Setup