google-maps-services-js icon indicating copy to clipboard operation
google-maps-services-js copied to clipboard

Incorrect typings for DirectionsStep.step, (should be DirectionsStep[])

Open sovietspaceship opened this issue 9 months ago • 2 comments

I'm using @googlemaps/google-maps-services-js 3.4.0.

The DirectionsStep type contains a steps property which should be DirectionsStep[], but the included typings in common.d.ts define it as just DirectionsStep. In the API responses it's clearly an array, and the comment on it also says that it's supposed to be an array. Also, it should be optional.

Unless I'm missing something, I believe this is what common.d.ts:1024 should be:

export interface DirectionsStep {
    /* ... */
    /**
     * contains detailed directions for walking or driving steps in transit directions.
     * Substeps are only available when `travel_mode` is set to "transit".
     * The inner `steps` array is of the same type as `steps`.
     */
-    steps: DirectionsStep;
+    steps?: DirectionsStep[];
}

sovietspaceship avatar Feb 23 '25 23:02 sovietspaceship

This has been bothering me for weeks.

The same, by the way, for transit_details in the same type; It is undefined if TravelMode.transit is not applicable to that step.

svdgoor avatar Mar 03 '25 10:03 svdgoor

export interface DirectionsStep {
    /* ... */
    /**
     * contains detailed directions for walking or driving steps in transit directions.
     * Substeps are only available when `travel_mode` is set to "transit".
     * The inner `steps` array is of the same type as `steps`.
     */
-    steps: DirectionsStep;
+    steps?: DirectionsStep[];
     /* ... */
     /** contains transit specific information. This field is only returned with travel_mode is set to "transit". */
-    transit_details: TransitDetails
+    transit_details: TransitDetails | undefined;
}

svdgoor avatar Mar 03 '25 10:03 svdgoor