0 of 6 problems solved0%
5 of 6

Touch Sellable

Operator precedence matters: parentheses decide whether you intersect the union as a whole or only one side. (A | B) & C means “either A or B, plus C”. Use this to say every sellable item also has audit fields.

// coding example
type A = { a: 1 };
type B = { b: 2 };
type C = { c: 3 };
// (A | B) & C ⇒ either {a} or {b}, plus {c}

Return a new object with an updated timestamp.

Your Task

Update updatedAt on a sellable without mutation.

  • Define type Product = { sku: string; price: number } and type Service = { code: string; hourly: number }.
  • Define type Audited = { createdAt: number; updatedAt: number } and type Sellable = (Product | Service) & Audited.
  • Implement function touch(s: Sellable, ms: number): Sellable that returns a new object with updatedAt = ms and all other fields preserved.
  • Do not mutate the input.