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

TS5.0 Const Type Parameters: use <const T> for immutable literal inference

TypeScript 5.0 introduced const type parameters (<const T>), allowing functions to infer exact literal tuple and object types without 'as const'.

๐Ÿ’ก Verified Solution

Add const modifier to type parameters: function parse<const T>(val: T): T.

Patch / Unified Code Diff:
--- old.ts
+++ new.ts
@@ -1,2 +1,2 @@
-function getNames<T extends readonly string[]>(names: T): T
+function getNames<const T extends readonly string[]>(names: T): T
๐Ÿงช 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