```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 (const line of lines) {
    // Ignore blank lines and comments
    if (line.trim() === "" || line.trim().startsWith("#")) {
      continue;
    }

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

    // Validate key and value
    if (key === undefined) {
      throw new Error(`Line "${line}" has no "="`);
    }
    const trimmedKey = key.trim();
    if (trimmedKey === "") {
      throw new Error(`Line "${line}" has an empty key`);
    }

    // Assign to the config object, avoiding prototype pollution
    Object.defineProperty(config, trimmedKey, { value: value?.trim() ?? "", writable: true, enumerable: true, configurable: true });
  }

  return config;
}
```