```ts
/** Firmware build selection within an installed release line. */

export function compareBuilds(a: string, b: string): number {
  const left = a.split(".").map(Number);
  const right = b.split(".").map(Number);
  const width = Math.max(left.length, right.length);
  for (let i = 0; i < width; i += 1) {
    const x = i < left.length ? left[i] : 0;
    const y = i < right.length ? right[i] : 0;
    if (x > y) {
      return 1;
    }
    if (x < y) {
      return -1;
    }
  }
  return 0;
}

export function pickUpgrade(installed: string, offers: string[]): string | null {
  if (!Array.isArray(offers)) {
    throw new Error("offers argument must be a list");
  }

  let best: string | null = null;
  for (const offer of offers) {
    if (typeof offer !== "string") {
      throw new Error("offer must be a string");
    }
    const parts = offer.split(".");
    if (parts.length < 2 || !parts.every(part => /^\d+(\.\d+)?$/.test(part))) {
      throw new Error("offer must be of the dotted form 'x.y.z'");
    }

    if (installed === offer) {
      continue;
    }
    if (compareBuilds(offer, installed) >= 0) {
      best = offer;
    }
  }
  return best;
}
```