```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")) {
    line = line.trim();
    if (!line || line.startsWith("#")) {
      continue;
    }
    const [key, value] = line.split("=");
    key = key.trim();
    value = value.trim();

    if (!key) {
      throw new Error(`Empty key on line: ${line}`);
    }

    if (config.hasOwnProperty(key)) {
      throw new Error(`Duplicate key: ${key} on line: ${line}`);
    }

    // Ensure the value does not contain a "="
    if (value.includes("=")) {
      throw new Error(`Invalid value with "=" on line: ${line}`);
    }

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