```typescript
/** 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("=", 2).map((part) => part.trim());
    if (!key) {
      throw new Error(`Line ${lineNumber} has an empty key`);
    }
    config[key] = value;
  }
  return config;
}

// Helper function to get the current line number (not shown in the provided text)
function getCurrentLineNumber() {
  const lines = text.split("\n");
  return lines.findIndex((_, index) => index === lineNumber);
}
```