Per-entry narrowed output type for TimeSeries.reduce(mapping). For
an AggregateMap with literal reducer names, each field narrows to
the specific value kind the reducer produces:
The branches are enumerated inline (rather than delegated to
AggregateKindForColumn + NormalizedValueForKind) because the
inlined form is the only shape TypeScript accepts in the same
compilation unit as the arrayAggregate / arrayExplode overloads —
more-delegated variants trip TS2394 on those overloads' compatibility
with their implementation signature. The narrow logic is intentionally
duplicated here; keep it in sync with AggregateKindForColumn in
./aggregate.ts if the set of numeric / array-producing reducers
changes.
Branches:
Numeric-output reducers ('sum', 'avg', 'count', 'median',
'stdev', 'difference', any p${number}) → number | undefined.
Array-output reducers ('unique', 'samples', any top${number}) →
ReadonlyArray<T> | undefined, where T is the source column's
element type — ReadonlyArray<string> for a kind: 'string'
column, ReadonlyArray<number> for kind: 'number', etc.
Array-kind source columns fall back to the wide
ReadonlyArray<ScalarValue> | undefined.
Source-preserving reducers ('first', 'last', 'keep') → the
source column's value type (number, string, or boolean —
undefined included). Array-kind source columns fall back to
ColumnValue | undefined because tracking element kind is out of
scope for the schema.
Spec entries ({ from, using }, { from, using, kind }) narrow
the same way, sourcing the column kind from from rather than the
key. An explicit kind on the spec widens to that kind's value
type. Before v0.23.0 a spec entry in reduce fell back to the wide
ColumnValue | undefined (audit v2 §5 F1) — it now narrows per
reducer.
Custom reducer functions fall back to ColumnValue | undefined —
their output kind is set at runtime and the type system can't see
through it.
The spec and shorthand branches share ReduceValueForReducer, which
stays inline (nested conditionals, no delegation to schema-layer kind
types) to keep the type compatible with the arrayAggregate /
arrayExplode overloads' implementation signature — see the note
above on TS2394.
Per-entry narrowed output type for
TimeSeries.reduce(mapping). For anAggregateMapwith literal reducer names, each field narrows to the specific value kind the reducer produces:The branches are enumerated inline (rather than delegated to
AggregateKindForColumn+NormalizedValueForKind) because the inlined form is the only shape TypeScript accepts in the same compilation unit as thearrayAggregate/arrayExplodeoverloads — more-delegated variants trip TS2394 on those overloads' compatibility with their implementation signature. The narrow logic is intentionally duplicated here; keep it in sync withAggregateKindForColumnin./aggregate.tsif the set of numeric / array-producing reducers changes.Branches:
'sum','avg','count','median','stdev','difference', anyp${number}) →number | undefined.'unique','samples', anytop${number}) →ReadonlyArray<T> | undefined, whereTis the source column's element type —ReadonlyArray<string>for akind: 'string'column,ReadonlyArray<number>forkind: 'number', etc. Array-kind source columns fall back to the wideReadonlyArray<ScalarValue> | undefined.'first','last','keep') → the source column's value type (number,string, orboolean—undefinedincluded). Array-kind source columns fall back toColumnValue | undefinedbecause tracking element kind is out of scope for the schema.{ from, using },{ from, using, kind }) narrow the same way, sourcing the column kind fromfromrather than the key. An explicitkindon the spec widens to that kind's value type. Before v0.23.0 a spec entry inreducefell back to the wideColumnValue | undefined(audit v2 §5 F1) — it now narrows per reducer.ColumnValue | undefined— their output kind is set at runtime and the type system can't see through it.The spec and shorthand branches share
ReduceValueForReducer, which stays inline (nested conditionals, no delegation to schema-layer kind types) to keep the type compatible with thearrayAggregate/arrayExplodeoverloads' implementation signature — see the note above on TS2394.