Skip to content

docs(data-source): clarify extra option as driver-native escape hatch - #12368

Merged
naorpeled merged 2 commits into
typeorm:masterfrom
naorpeled:chore/resolve-extra-option-todo
May 19, 2026
Merged

naorpeled merged 2 commits into
typeorm:masterfrom
naorpeled:chore/resolve-extra-option-todo

Conversation

@naorpeled

Copy link
Copy Markdown
Member

Summary

  • Resolve the stale // todo: deprecate this and move all database-specific types into hts own connection options object. on BaseDataSourceOptions#extra.
  • Replace the TODO with JSDoc explaining that extra is the intentional escape hatch for driver-native settings (passed through to pg, mysql2, tedious, mongodb, etc.), and that users should prefer the typed per-driver options when they exist.

Context

extra is used by every driver (src/driver/*/[Driver].ts) to spread driver-native options into the underlying client. Removing it would require modeling every driver's native option surface as typed options first — out of scope for a cleanup change. Documenting the existing intent is the minimal resolution.

Not a breaking change — API unchanged, JSDoc only.

Test plan

  • pnpm run typecheck
  • Visual review of the rendered JSDoc

Resolve the stale todo that proposed deprecating `extra`. `extra` is
used by every driver to pass through options to the underlying client
library and is the documented escape hatch for driver-native settings
not modeled as typed options. Update the JSDoc to reflect this intent
instead of leaving a deprecation note that has no follow-up plan.
@pkg-pr-new

pkg-pr-new Bot commented Apr 17, 2026 •

Copy link
Copy Markdown
  • typeorm-sql-js-example

    npm i https://pkg.pr.new/typeorm@12368
    

commit: 131e8c1

@naorpeled
naorpeled marked this pull request as ready for review April 17, 2026 17:07
Copilot AI review requested due to automatic review settings April 17, 2026 17:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Clarifies the intent of BaseDataSourceOptions#extra by replacing a stale TODO with JSDoc describing extra as an escape hatch for passing driver-native options through to underlying database client libraries.

Changes:

  • Removed outdated TODO comment on BaseDataSourceOptions#extra
  • Added JSDoc explaining extra as the driver-native “escape hatch” and recommending typed per-driver options when available

Comment on lines +131 to +132
* Extra connection options passed through to the underlying driver client
* (e.g. `pg`, `mysql2`, `tedious`, `mongodb`).

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc currently states extra is "passed through to the underlying driver client", but options.extra is only forwarded by some drivers (e.g. PostgresDriver.ts:1738-1754) and is unused in others (e.g. no extra usage in src/driver/sqlite-abstract/). Consider qualifying this wording (e.g. "for drivers that wrap a native client") so it stays accurate across all supported drivers.

Suggested change
* Extra connection options passed through to the underlying driver client
* (e.g. `pg`, `mysql2`, `tedious`, `mongodb`).
* Extra connection options used by some drivers and, for drivers that wrap
* a native client, passed through to that client (e.g. `pg`, `mysql2`,
* `tedious`, `mongodb`).

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +137
* options on the per-driver `DataSourceOptions`. Prefer the typed
* per-driver options when they exist; `extra` is the escape hatch for
* anything the driver supports but TypeORM does not expose directly.

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataSourceOptions is a union of all driver options (src/data-source/DataSourceOptions.ts:22+), so the phrase "per-driver DataSourceOptions" reads a bit self-contradictory. Consider rewording to "driver-specific *DataSourceOptions" (e.g. PostgresDataSourceOptions) or "the driver-specific DataSourceOptions interface" to avoid confusion.

Suggested change
* options on the per-driver `DataSourceOptions`. Prefer the typed
* per-driver options when they exist; `extra` is the escape hatch for
* anything the driver supports but TypeORM does not expose directly.
* options on the driver-specific DataSourceOptions interface. Prefer the
* typed driver-specific options when they exist; `extra` is the escape hatch
* for anything the driver supports but TypeORM does not expose directly.

Copilot uses AI. Check for mistakes.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0)

Grey Divider


Remediation recommended

1. Misleading per-driver options name 🐞 Bug ⚙ Maintainability ⭐ New
Description
The new JSDoc for BaseDataSourceOptions.extra says typed options live on the per-driver
DataSourceOptions, but DataSourceOptions is a single union type (not a per-driver interface).
This can misdirect users to the wrong type/docs and obscures where the typed driver-specific options
actually are (e.g., PostgresDataSourceOptions, MysqlDataSourceOptions).
Code

src/data-source/BaseDataSourceOptions.ts[R134-136]

+     * Use this for driver-native settings that are not modeled as typed
+     * options on the per-driver `DataSourceOptions`. Prefer the typed
+     * per-driver options when they exist; `extra` is the escape hatch for
Evidence
The extra JSDoc explicitly references “per-driver DataSourceOptions”, but the codebase defines
DataSourceOptions as a single union type and uses distinct driver-specific *DataSourceOptions
interfaces per database driver, so the JSDoc wording is inaccurate.

src/data-source/BaseDataSourceOptions.ts[130-139]
src/data-source/DataSourceOptions.ts[19-39]
src/driver/postgres/PostgresDataSourceOptions.ts[5-14]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The JSDoc for `BaseDataSourceOptions.extra` refers to typed options being on the per-driver `DataSourceOptions`, but `DataSourceOptions` is the *global union type* across all drivers. This phrasing is misleading and should instead reference the driver-specific `*DataSourceOptions` interfaces (or “driver-specific options interfaces/types”).

### Issue Context
- `DataSourceOptions` is defined as a union of driver-specific options types.
- Each driver has its own options interface like `PostgresDataSourceOptions`, `MysqlDataSourceOptions`, etc.

### Fix Focus Areas
- src/data-source/BaseDataSourceOptions.ts[130-139]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Overbroad extra JSDoc 🐞 Bug ⚙ Maintainability
Description
The updated JSDoc states extra is passed through to the underlying driver client and can be used
for “anything the driver supports”, but some drivers never apply extra when constructing the
underlying connection/client options, so settings provided via extra will be silently ignored for
those drivers.
Code

src/data-source/BaseDataSourceOptions.ts[R131-137]

+     * Extra connection options passed through to the underlying driver client
+     * (e.g. `pg`, `mysql2`, `tedious`, `mongodb`).
    *
-     * todo: deprecate this and move all database-specific types into hts own connection options object.
+     * Use this for driver-native settings that are not modeled as typed
+     * options on the per-driver `DataSourceOptions`. Prefer the typed
+     * per-driver options when they exist; `extra` is the escape hatch for
+     * anything the driver supports but TypeORM does not expose directly.
Evidence
The new JSDoc describes extra as a generic pass-through escape hatch. This is true for some
drivers (e.g., Postgres merges options.extra into the driver pool options), but other drivers
construct their underlying client options without referencing extra at all (e.g., BetterSqlite3
and Sqljs), meaning the documentation overstates how universally extra is honored.

src/data-source/BaseDataSourceOptions.ts[130-139]
src/driver/postgres/PostgresDriver.ts[1736-1754]
src/driver/better-sqlite3/BetterSqlite3Driver.ts[133-148]
src/driver/sqljs/SqljsDriver.ts[287-304]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`BaseDataSourceOptions#extra` JSDoc currently reads like a universal guarantee that `extra` is always passed through to the underlying driver client and can be used for “anything the driver supports”. In the codebase, some drivers do merge `extra` into underlying client options (e.g. Postgres), but others don’t reference `extra` when creating the underlying connection at all (e.g. better-sqlite3/sqljs), so the doc is misleading.
### Issue Context
This PR is intentionally JSDoc-only, so the best fix is to adjust wording to accurately reflect current behavior rather than implying universal support.
### Fix Focus Areas
- src/data-source/BaseDataSourceOptions.ts[130-139]
### Suggested direction
- Change wording to something like: “For drivers that support it, `extra` is merged into the underlying client options…”
- Avoid absolute language like “anything the driver supports”.
- Optionally, keep examples but ensure they refer to the actual client package being configured (and/or phrase as illustrative, not exhaustive).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Previous review results

Review updated until commit 131e8c1

Results up to commit db53b71


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)


Remediation recommended
1. Overbroad extra JSDoc 🐞 Bug ⚙ Maintainability
Description
The updated JSDoc states extra is passed through to the underlying driver client and can be used
for “anything the driver supports”, but some drivers never apply extra when constructing the
underlying connection/client options, so settings provided via extra will be silently ignored for
those drivers.
Code

src/data-source/BaseDataSourceOptions.ts[R131-137]

+     * Extra connection options passed through to the underlying driver client
+     * (e.g. `pg`, `mysql2`, `tedious`, `mongodb`).
     *
-     * todo: deprecate this and move all database-specific types into hts own connection options object.
+     * Use this for driver-native settings that are not modeled as typed
+     * options on the per-driver `DataSourceOptions`. Prefer the typed
+     * per-driver options when they exist; `extra` is the escape hatch for
+     * anything the driver supports but TypeORM does not expose directly.
Evidence
The new JSDoc describes extra as a generic pass-through escape hatch. This is true for some
drivers (e.g., Postgres merges options.extra into the driver pool options), but other drivers
construct their underlying client options without referencing extra at all (e.g., BetterSqlite3
and Sqljs), meaning the documentation overstates how universally extra is honored.

src/data-source/BaseDataSourceOptions.ts[130-139]
src/driver/postgres/PostgresDriver.ts[1736-1754]
src/driver/better-sqlite3/BetterSqlite3Driver.ts[133-148]
src/driver/sqljs/SqljsDriver.ts[287-304]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`BaseDataSourceOptions#extra` JSDoc currently reads like a universal guarantee that `extra` is always passed through to the underlying driver client and can be used for “anything the driver supports”. In the codebase, some drivers do merge `extra` into underlying client options (e.g. Postgres), but others don’t reference `extra` when creating the underlying connection at all (e.g. better-sqlite3/sqljs), so the doc is misleading.

### Issue Context
This PR is intentionally JSDoc-only, so the best fix is to adjust wording to accurately reflect current behavior rather than implying universal support.

### Fix Focus Areas
- src/data-source/BaseDataSourceOptions.ts[130-139]

### Suggested direction
- Change wording to something like: “For drivers that support it, `extra` is merged into the underlying client options…”
- Avoid absolute language like “anything the driver supports”.
- Optionally, keep examples but ensure they refer to the actual client package being configured (and/or phrase as illustrative, not exhaustive).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


ⓘ The new review experience is currently in Beta. Learn more

Qodo Logo

@G0maa
G0maa self-requested a review April 20, 2026 18:35
@naorpeled
naorpeled enabled auto-merge (squash) May 19, 2026 18:26
@naorpeled
naorpeled merged commit 7779c30 into typeorm:master May 19, 2026
46 checks passed
@github-actions github-actions Bot added this to the 1.0 milestone May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants