0 of 6 problems solved0%
1 of 6

Audit Merge (Intersection)

Intersections combine multiple object types into one value that has all properties. If A is { id: string } and B is { createdAt: number }, then A & B has both id and createdAt. Use this to enrich a base record with audit fields.

type A = { id: string };
type B = { createdAt: number; updatedAt: number };
// A & B has both id and the audit fields

Return a new object rather than mutating inputs so callers can reuse both.

Your Task

Build a merged record with all fields from base and audit.

  • Define type Base = { id: string; name: string } and type Audit = { createdAt: number; updatedAt: number }.
  • Write function addAudit(base: Base, audit: Audit): Base & Audit.
  • Return a new object that includes every property from both inputs.
  • Do not mutate the inputs.