Skip to content

Unexpected structure of createPool result: config is nested under pool.connectionConfig #3691

@IamsadVN

Description

@IamsadVN

📝 Description:

Using TypeScript with mysql2/promise, I expected the Pool object to expose a config property directly, but it's deeply nested under pool.connectionConfig, and the type definitions do not reflect this structure.

📄 Issue Body:

🧩 Context

I'm using mysql2/promise in a TypeScript project. While working with a Pool instance (created via mysql.createPool(...)), I noticed that accessing pool.config returns undefined.

I expected to access the connection options like host, user, password, etc., via pool.config, based on the PoolConnection type.

However, after inspecting the structure of the pool object, I found that:

pool.config // undefined
pool.pool.config // still undefined
pool.pool.config.connectionConfig // contains the expected values

Only pool.pool.config.connectionConfig contains the values I originally passed into createPool().

📦 Problem

  • The actual structure is quite nested (pool.pool.config.connectionConfig).
  • The Pool type from mysql2/promise does not expose or document this structure.
  • This creates confusion and TypeScript type mismatches when accessing configuration properties.

📸 Images

Image Image Image Image Image Image

✅ Suggested Fix

Either:

  • Expose the configuration object more clearly (e.g., make pool.config work as expected), or
  • Update the TypeScript definitions to reflect the internal structure more accurately, so developers can access properties like host, user, etc., through the correct path.

Thanks for maintaining this project!

(i use chatgpt to help me write and translate the problem i want to make you know)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions