MCPcopy Index your code
hub / github.com/TanStack/ai / transformNullsToUndefined

Function transformNullsToUndefined

packages/ai-utils/src/transforms.ts:30–51  ·  view source on GitHub ↗
(obj: T)

Source from the content-addressed store, hash-verified

28 * synthesized.
29 */
30export function transformNullsToUndefined<T>(obj: T): T {
31 if (obj === null) {
32 return undefined as T
33 }
34
35 if (typeof obj !== 'object') {
36 return obj
37 }
38
39 if (Array.isArray(obj)) {
40 return obj.map((item) => transformNullsToUndefined(item)) as T
41 }
42
43 const result: Record<string, unknown> = {}
44 for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
45 if (value === null) {
46 continue
47 }
48 result[key] = transformNullsToUndefined(value)
49 }
50 return result as T
51}
52
53/**
54 * Records exactly where strict-mode null-widening synthesized a `null`, so

Callers 1

transforms.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected