```ts
/** The KEY=VALUE pairs of a config file. */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  const lines = text.split("\n");

  for (let i = 0; i < lines.length; i++) {
    let line = lines[i].trim();

    // Ignore blank lines and comments
    if (line === "" || line.startsWith("#")) {
      continue;
    }

    // Split on the first '=' only
    const [key, value] = line.split("=", 2);

    if (key === undefined) {
      throw new Error(`Line ${i + 1}: No '=' found`);
    }

    const trimmedKey = key.trim();

    if (trimmedKey === "") {
      throw new Error(`Line ${i + 1}: Empty key`);
    }

    // Ensure the key does not reach Object.prototype
    if (Object.prototype.hasOwnProperty.call(config, trimmedKey)) {
      continue;
    }

    config[trimmedKey] = value !== undefined ? value.trim() : "";
  }

  return config;
}
```