```ts
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    if (!line.trim()) continue; // Skip blank lines

    const [key, value] = line.split("=", 2);
    if (key === undefined || key.startsWith("#")) {
      throw new Error(`Invalid line: ${line}`);
    }

    config[key.trim()] = value?.trim();
  }
  return config;
}
```