```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")) {
    // Trim whitespace around the line
    const trimmedLine = line.trim();
    
    if (!trimmedLine) continue; // Skip if it's just a blank line
    
    if (trimmedLine.startsWith("#")) continue; // Ignore comments starting with #

    const [key, value] = trimmedLine.split("=", 2);
    if (!key || !value) {
      throw new Error(`Invalid config line: ${line}`); // Throw for empty or no =
    }

    // Trim whitespace around the key and the value
    const cleanKey = key.trim();
    const cleanValue = value.trim();

    // Skip "__proto__" key to avoid touching Object.prototype
    if (cleanKey === "__proto__") continue;

    config[cleanKey] = cleanValue;
  }

  return config;
}
```