Repository navigation
docs(data-source): clarify extra option as driver-native escape hatch - #12368
Conversation
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.
commit: |
There was a problem hiding this comment.
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
extraas the driver-native “escape hatch” and recommending typed per-driver options when available
| * Extra connection options passed through to the underlying driver client | ||
| * (e.g. `pg`, `mysql2`, `tedious`, `mongodb`). |
There was a problem hiding this comment.
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.
| * 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`). |
| * 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. |
There was a problem hiding this comment.
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.
| * 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. |
Code Review by Qodo
1. Misleading per-driver options name
|
Summary
// todo: deprecate this and move all database-specific types into hts own connection options object.onBaseDataSourceOptions#extra.extrais the intentional escape hatch for driver-native settings (passed through topg,mysql2,tedious,mongodb, etc.), and that users should prefer the typed per-driver options when they exist.Context
extrais 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