```ts
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    const trimmedLine = line.trim();
    if (!trimmedLine || trimmedLine.startsWith("#")) continue;
    const parts = trimmedLine.split("=");
    if (parts.length !== 2) throw new Error(`Invalid line: ${trimmedLine}`);
    const key = parts[0].trim();
    const value = parts[1].trim();
    if (Object.prototype.hasOwnProperty.call(config, key)) {
      throw new Error(`Duplicate key: ${key} on line ${line}`);
    }
    config[key] = value;
  }
  return config;
}
```