Details
-
New Feature
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
Users writing typed query() / execute() calls currently have to hand-author the row + FieldInfo[] shape every time, either as T[] & ( meta: FieldInfo[]) (default mode) or as [T, FieldInfo[]] (when metaAsArray: true).
The intersection with property pattern is unintuitive to discover from the existing FieldInfo export alone, and the tuple shape is easy to get subtly wrong.
Two helper types are added to types/share.d.ts (and the matching .d.cts) so users can express the intended shape directly:
RowsWithMeta<T>: T[] & ( meta: FieldInfo[] ), default shape, rows with the non-enumerable meta attached.
WithMeta<T>: [T, FieldInfo[]], with an identity branch when T is already a [any, FieldInfo[]] tuple so the legacy hand-rolled pattern keeps compiling.
Example:
const rows = await conn.query<RowsWithMeta<MyRow>>('SELECT ...');
|
rows.meta; // FieldInfo[]
|
or when option `metaAsArray: true` is set :
const [rows, meta] = await conn.query<WithMeta<MyRow[]>>('SELECT ...');
|
const [res, meta] = await conn.query<WithMeta<UpsertResult>>('UPDATE ...');
|
No runtime changes, types-only ergonomics.