-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
Bug Description
The TypeScript definition for GeoShape.coordinates() is incomplete and doesn't support Polygon geometries.
https://docs.opensearch.org/latest/field-types/supported-field-types/geo-shape/#polygon
Current Type Definition
coordinates(coords: number[][] | number[]): this;Issue
The current typing only supports:
Point: number[] → [longitude, latitude]
LineString: number[][] → [[lon, lat], [lon, lat], ...]
But it's missing support for:
Polygon: number[][][] → [[[lon, lat], [lon, lat], ...]]
Expected Type Definition
coordinates(coords: number[] | number[][] | number[][][]): this;Reproduction
import builder from 'elastic-builder';
const polygonCoords: number[][] = [[2.415381, 49.383599], [2.413381, 49.38364]];
// This works at runtime but fails TypeScript compilation
const geoShape = builder
.geoShape()
.type('polygon')
.coordinates([polygonCoords]); // ❌ TypeScript error
// Current workaround needed:
const geoShapeWorkaround = builder
.geoShape()
.type('polygon')
.coordinates([polygonCoords] as any); // ✅ Works but requires castEnvironment
elastic-builder version: 3.2.0
TypeScript version: 5.9.2
Impact
This forces developers to use as any casts when working with Polygon geometries, losing type safety.
Thank you
Metadata
Metadata
Assignees
Labels
No labels