```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 = (cellText: string): number => {
    if (cellText.startsWith("=")) {
      return cellText
        .slice(1)
        .split("+")
        .map((part) => part.trim())
        .reduce((sum, ref) => sum + evaluateCell(cells[ref]), 0);
    }
    return parseInt(cellText, 10);
  };

  const originalValues = new Map<string, number>();
  for (const [cell, text] of Object.entries(cells)) {
    originalValues.set(cell, evaluateCell(text));
  }

  cells[name] = replacement;

  const changed: string[] = [];
  for (const [cell, text] of Object.entries(cells)) {
    if (evaluateCell(text) !== originalValues.get(cell)) {
      changed.push(cell);
    }
  }

  return changed.sort();
}
```