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

    if (key === "__proto__") {
      config[key] = value;
    } else {
      try {
        config[key] = JSON.parse(value);
      } catch (e) {
        throw new Error(`Invalid value for key "${key}" on line ${line}`);
      }
    }
  }
  return config;
}
```