```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() === "") continue;
    if (line.startsWith("#")) continue;

    const [key, value] = line.split("=");
    key = key.trim();
    value = value.trim();

    if (!key) throw new Error(`Config file line ${line} has no key`);
    if (config.hasOwnProperty(key)) throw new Error(
      `Config file line ${line} has duplicate key "${key}"`
    );

    config[key] = value;
  }
  return config;
}
```