```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("Invalid input types");
  }

  const length = Math.max(0, width - code.length);
  return length === 0 ? code : `0${code}`.padStart(width, "0");
}
```