```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;
    const i = line.indexOf("=");
    if (i === -1) throw new Error(`Line ${text.split("\n").indexOf(line) + 1} has no '='`);
    const key = line.slice(0, i).trim();
    if (key.length === 0) throw new Error(`Empty key at line ${text.split("\n").indexOf(line) + 1}`);
    const value = line.slice(i + 1).trim();
    config[key] = value;
  }
  return config;
}
```