The signature flatten<T, R>(target: T, ...): R leaves T unconstrained, so TypeScript lets you pass null | undefined. However, at runtime the function expects an object and crashes.
Reproduction: https://playcode.io/2592924
Ideally this is prevented at compile time, by constraining T:
export function flatten<T extends object, R = Record<string, unknown>>(
target: T,
options?: FlattenOptions
): R;
Related: #185
The signature flatten<T, R>(target: T, ...): R leaves T unconstrained, so TypeScript lets you pass
null | undefined. However, at runtime the function expects an object and crashes.Reproduction: https://playcode.io/2592924
Ideally this is prevented at compile time, by constraining T:
Related: #185