```ts
export function changedCells(
  cells: Record<string, string>,
  name: string,
  replacement: string,
): string[] {
  if (!(name in cells)) {
    throw new Error(`unknown cell ${name}`);
  }
  if (cells[name] === replacement) {
    return [];
  }

  const evaluateCell = (cell: string): number => {
    if (!cell.startsWith("=")) {
      return parseInt(cell, 10);
    }
    const refs = cell.slice(1).split("+").map((part) => part.trim());
    return refs.reduce((sum, ref) => sum + evaluateCell(ref), 0);
  };

  const oldValue = cells[name];
  cells[name] = replacement;
  const changed = Object.keys(cells)
    .filter((cell) => evaluateCell(cell) !== evaluateCell(cell))
    .sort();
  cells[name] = oldValue; // Revert the change to keep the original state

  return changed;
}
```