Implement squashObject(obj) — take a deeply nested object and flatten it into a single-level object, where each key is the dot-joined path from the root down to a value. squashObject({ a: { b: 1 } }) becomes { 'a.b': 1 }. Think of it as turning a folder tree into a flat list of full file paths: docs/notes/todo.txt instead of a docs folder containing a notes folder containing todo.txt. This is the same flattening that config loaders and form libraries do to turn user.address.city into one addressable key. The reverse operation — expanding dotted keys back into a tree — is its own question, unsquash-object; keep this one symmetric with it so a round-trip is lossless.
// obj: a plain object that may contain nested plain objects to any depth.
// returns: a new single-level object. Every key is a dot-joined path string;
// every value is a LEAF — a primitive, null, or an array, kept as-is.
function squashObject(obj): Record<string, unknown>;
// One level of nesting: the two keys join with a dot.
squashObject({ a: { b: 1 } });
// → { 'a.b': 1 }
// Mixed depth: flat keys stay flat, nested keys carry their full path.
squashObject({ a: 1, b: { c: 2, d: { e: 3 } } });
// → { a: 1, 'b.c': 2, 'b.d.e': 3 }
// Arrays and null are leaves — kept whole, never expanded.
squashObject({ tags: ['x', 'y'], meta: { author: null } });
// → { tags: ['x', 'y'], 'meta.author': null }
{ a: [1, 2] } becomes { a: [1, 2] }, NOT { 'a.0': 1, 'a.1': 2 }. Keep the array reference as-is; don't explode it into numeric-index keys.null is a leaf. typeof null is 'object', but null has no keys to walk — treat it as a value, not something to recurse into.{ a: {}, b: 1 } becomes { b: 1 }. An empty branch has no leaves, so there is no path to record and it contributes no key. (Test this; it's the trickiest rule.)obj; build and return a fresh result object.{ 'a.b': { c: 1 } } flattens to { 'a.b.c': 1 } — which is indistinguishable from { a: { b: { c: 1 } } }. That's a known limitation of dot-delimited flattening; join verbatim and don't try to escape it here.