```ts
/**
 * A code padded with zeros to a fixed width.
 */
export function padCode(code: string, width: number): string {
  if (typeof code !== "string" || typeof width !== "number") {
    throw new Error("Both code and width must be strings or numbers.");
  }

  let fixedCode = code;
  while (fixedCode.length < width) {
    fixedCode = "0" + fixedCode;
  }
  return fixedCode;
}
```