Description
Currently, the doubles property in AnalyticsEngineDataPoint is strictly typed as number[]. This is inconsistent with the indexes and blobs fields, which both allow null values to represent missing data in specific positions.
Since Workers Analytics Engine supports sparse arrays, the current type definition forces a friction point for TypeScript users.
Impact
TypeScript users wishing to record sparse double fields are currently prohibited from passing arrays containing null (e.g., [0, null, 1]). To work around this, users are forced to use type casting:
// Current workaround required:
doubles: [10, null, 20] as unknown as number[]
Proposed Change
Update the doubles property to allow null values within the array to align with the underlying capabilities and other property definitions.
export interface AnalyticsEngineDataPoint {
indexes?: ((ArrayBuffer | string) | null)[];
- doubles?: number[];
+ doubles?: (number | null)[];
blobs?: ((ArrayBuffer | string) | null)[];
}
https://github.com/cloudflare/workerd/blob/main/src/workerd/api/analytics-engine.h#L33-L49
Description
Currently, the
doublesproperty inAnalyticsEngineDataPointis strictly typed asnumber[]. This is inconsistent with the indexes and blobs fields, which both allow null values to represent missing data in specific positions.Since Workers Analytics Engine supports sparse arrays, the current type definition forces a friction point for TypeScript users.
Impact
TypeScript users wishing to record sparse double fields are currently prohibited from passing arrays containing null (e.g., [0, null, 1]). To work around this, users are forced to use type casting:
Proposed Change
Update the
doublesproperty to allownullvalues within the array to align with the underlying capabilities and other property definitions.export interface AnalyticsEngineDataPoint { indexes?: ((ArrayBuffer | string) | null)[]; - doubles?: number[]; + doubles?: (number | null)[]; blobs?: ((ArrayBuffer | string) | null)[]; }https://github.com/cloudflare/workerd/blob/main/src/workerd/api/analytics-engine.h#L33-L49