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
types.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', 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.
Custom reducer functions and AggregateOutputSpec entries fall
back to ColumnValue | undefined — their output kind is set at
runtime and the type system can't see through it.
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 withAggregateKindForColumnintypes.tsif the set of numeric / array-producing reducers changes.Branches:
'sum','avg','count','median','stdev','difference', anyp${number}) →number | undefined.'unique', 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.AggregateOutputSpecentries fall back toColumnValue | undefined— their output kind is set at runtime and the type system can't see through it.