```ts
/** The KEY=VALUE pairs of a config file. */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    if (line.trim().startsWith("#") || !line.includes("=")) continue;
    const [key, value] = line.replace(/^[ \t]+/, "").split("=");
    if (Object.prototype.hasOwnProperty.call(config, key)) throw new Error(`Duplicate key: ${key}`);
    config[key] = value;
  }
  return config;
}
```