```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() || line.startsWith('#')) continue;
    let [key, value] = line.split('=', 2);
    key = key.trim();
    value = value.trim();
    if (!key || !value) throw new Error(`Line ${text.indexOf(line) + 1}: empty key or no '='`);
    config[key] = value;
  }
  return config;
}
```