```typescript
/**
 * Parse a config file and return its contents as a plain data object.
 */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    if (!line || line.startsWith("#")) continue;
    const trimmedLine = line.trim();
    const [key, value] = trimmedLine.split("=", 2);
    if (!key || !value) throw new Error(`Invalid config line at ${line}: key or value is missing`);
    key = key.trim();
    value = value.trim();
    config[key] = value;
  }
  return config;
}
```